1
/*****************************************************************************
6
*****************************************************************************/
11
Args myargs[NUMARGS] = {
12
/*0*/ { "Input string id", "DROADH", NULL, NULL, FALSE, 'i', ARG_STRING, 0.0,0,NULL},
13
/*1*/ { "Output Seq-entry", "T", NULL, NULL, TRUE , 's', ARG_BOOLEAN, 0.0,0,NULL},
14
/*2*/ { "Output File Name", "getseq.out", NULL, NULL, FALSE, 'o', ARG_FILE_OUT, 0.0,0,NULL},
15
/*3*/ { "GenInfo Import id", "0", NULL, NULL, TRUE , 'g', ARG_INT, 0.0,0,NULL},
16
/*4*/ { "Id is GenBank accession", "F", NULL, NULL, TRUE , 'a', ARG_BOOLEAN, 0.0,0,NULL},
17
/*5*/ { "Id is GenBank locus", "T", NULL, NULL, TRUE , 'l', ARG_BOOLEAN, 0.0,0,NULL},
18
/*6*/ { "Id is PIR accession", "F", NULL, NULL, TRUE , 'b', ARG_BOOLEAN, 0.0,0,NULL},
19
/*7*/ { "Id is PIR locus", "F", NULL, NULL, TRUE , 'p', ARG_BOOLEAN, 0.0,0,NULL},
20
/*8*/ { "Return type 1=Bioseq,2=seg-set,3=nuc-prot,4=pub-set", "3", "1", "4", TRUE , 'r', ARG_INT, 0.0,0,NULL}};
24
Boolean seqentry; /* Arg 1 should always be TRUE */
25
Int2 retcode; /* Default is nuc-prot */
27
TextSeqIdPtr tsip; /* Text object, name, locus, or release */
28
SeqIdPtr sip; /* Same as a ValNodePtr, generic data ptr implemented */
29
/* as a choice and a union. Used to pass "tsip" data */
30
GiimPtr giim; /* GenInfo structure passed via "sip" in the special case */
31
/* of accessing a by GenInfo Id */
43
** Get program arguments
46
if ( !GetArgs("GetSeq 1.0", NUMARGS, myargs) ) return 1;
49
** Set parameters from the command line
52
seqentry = (Boolean)myargs[1].intvalue;
53
retcode = (Int2)myargs[8].intvalue;
56
** Instantiate ASN stream pointers and data.
57
** "sip" is used to pass the information in "tsip".
60
tsip = TextSeqIdNew();
61
sip = ValNodeNew(NULL);
62
sip->data.ptrvalue = tsip;
65
** From the command line, set either the name or accession field
66
** and the choice field of SeqIdPtr, this structure will be used
67
** to return an ASN stream from the CD-ROM
70
if (myargs[3].intvalue) { /* GenInfo import ID */
72
giim->id = myargs[3].intvalue;
73
sip->data.ptrvalue = giim;
74
sip->choice = SEQID_GIIM;
75
} else if (myargs[4].intvalue) { /* GenBank accession */
76
tsip->accession = myargs[0].strvalue;
77
sip->choice = SEQID_GENBANK;
78
} else if (myargs[5].intvalue) { /* GenBank locus */
79
tsip->name = myargs[0].strvalue;
80
sip->choice = SEQID_GENBANK;
81
} else if (myargs[6].intvalue) { /* PIR accession */
82
tsip->accession = myargs[0].strvalue;
83
sip->choice = SEQID_PIR;
84
} else if (myargs[7].intvalue) { /* PIR locus name */
85
tsip->name = myargs[0].strvalue;
86
sip->choice = SEQID_PIR;
90
** Initialize, open and otherwise prepare for CD-ROM or Network access.
93
if ( !EntrezInit("GetSeq", FALSE, &is_network) ) {
94
Message(MSG_ERROR, "Init failed");
99
** Using the SeqEntryPtr structure query the access routines
100
** and get the internal access number for this SeqEntry
102
** If the SeqEntryPtr comes up without a hit, report the error and
105
** Otherwise, use the internal access number, uid, and retrieve a
106
** a sequence entry ASN pointer, sep. If for some strange reason
107
** that it is NULL report the error and exit.
109
** Finaly, open an ASN file stream and write the sequence entry out
110
** in Print-Value format. Filename is from command line.
112
** Close the ASN file stream, free up memory create which was
113
** allocated elsewhere, sep.
117
uid = EntrezFindSeqId(sip);
119
Message(MSG_ERROR, "Couldn't find uid");
121
sip2 = EntrezSeqIdForGI(uid);
122
SeqIdPrint(sip2, buf, PRINTID_FASTA_LONG);
123
Message(MSG_OK, "Got back [%s]", buf);
124
sep = EntrezSeqEntryGet(uid, retcode);
126
Message(MSG_ERROR, "sep was NULL");
128
aipout = AsnIoOpen(myargs[2].strvalue, "w");
129
SeqEntryAsnWrite(sep, aipout, NULL);
135
Message(MSG_ERROR, "Oops");
139
** Close down the CD-ROM or Network access.
140
** Return OK to Operating system.