1
/*****************************************************************************
6
*****************************************************************************/
11
Args myargs[NUMARGS] = {
12
/*0*/ { "Input string id", "M65051", 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", "stdout", 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", "T", NULL, NULL, TRUE , 'a', ARG_BOOLEAN, 0.0,0,NULL},
17
/*5*/ { "Id is GenBank locus", "F", 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", "1", "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 */
38
** Get program arguments
41
if ( !GetArgs("GetSeq 1.1", NUMARGS, myargs) ) return 1;
44
** Set parameters from the command line
47
seqentry = (Boolean)myargs[1].intvalue;
48
retcode = (Int2)myargs[8].intvalue;
51
** Instantiate ASN stream pointers and data.
52
** "sip" is used to pass the information in "tsip".
55
tsip = TextSeqIdNew();
56
sip = ValNodeNew(NULL);
57
sip->data.ptrvalue = tsip;
60
** From the command line, set either the name or accession field
61
** and the choice field of SeqIdPtr, this structure will be used
62
** to return an ASN stream from the CD-ROM
65
if (myargs[3].intvalue) { /* GenInfo import ID */
67
giim->id = myargs[3].intvalue;
68
sip->data.ptrvalue = giim;
69
sip->choice = SEQID_GIIM;
70
} else if (myargs[4].intvalue) { /* GenBank accession */
71
tsip->accession = myargs[0].strvalue;
72
sip->choice = SEQID_GENBANK;
73
} else if (myargs[5].intvalue) { /* GenBank locus */
74
tsip->name = myargs[0].strvalue;
75
sip->choice = SEQID_GENBANK;
76
} else if (myargs[6].intvalue) { /* PIR accession */
77
tsip->accession = myargs[0].strvalue;
78
sip->choice = SEQID_PIR;
79
} else if (myargs[7].intvalue) { /* PIR locus name */
80
tsip->name = myargs[0].strvalue;
81
sip->choice = SEQID_PIR;
85
** Initialize, open and otherwise prepare for CD-ROM or Network access.
88
if ( !EntrezInit("getfasta", FALSE, NULL) ) {
89
Message(MSG_ERROR, "Init failed");
94
** Using the SeqEntryPtr structure query the access routines
95
** and get the internal access number for this SeqEntry
97
** If the SeqEntryPtr comes up without a hit, report the error and
100
** Otherwise, use the internal access number, uid, and retrieve a
101
** a sequence entry ASN pointer, sep. If for some strange reason
102
** that it is NULL report the error and exit.
104
** Write a (nucleic acid) sequence to output in FASTA format
106
** Close the ASN file stream, free up memory create which was
107
** allocated elsewhere, sep.
111
uid = EntrezFindSeqId(sip);
113
Message(MSG_ERROR, "Couldn't find uid");
115
sep = EntrezSeqEntryGet(uid, retcode);
117
Message(MSG_ERROR, "sep was NULL");
119
output = FileOpen(myargs[2].strvalue, "w");
120
SeqEntryToFasta(sep, output, TRUE); /* nucleic acid output */
126
Message(MSG_ERROR, "Oops");
130
** Close down the CD-ROM or Network access.
131
** Return OK to Operating system.