Int2 Main (void) { Char buf[256] = { '\0' }; /* Used below for name and version. */ Int2 status = 0; /* return value of function. */ StringCpy(buf, "bl2seq "); StringNCat(buf, BlastGetVersionNumber(), sizeof(buf)-StringLen(buf)-1); if (! GetArgs (buf, NUMARG, myargs)) { return (1); } UseLocalAsnloadDataAndErrMsg (); if (! SeqEntryLoad()) return 1; ErrSetMessageLevel(SEV_WARNING); if (myargs[ARG_FORCE_OLD].intvalue != 0) status = Main_old(); else status = Main_new(); FreeArgs(NUMARG, myargs); return status; }
Int2 Nlm_Main(void) { Boolean use_new_engine=FALSE; char buf[256] = { '\0' }; StringCpy(buf, "mgblast "); StringNCat(buf, BlastGetVersionNumber(), sizeof(buf)-StringLen(buf)-1); if (! GetArgs (buf, NUMARG, myargs)) return (1); UseLocalAsnloadDataAndErrMsg (); if (! SeqEntryLoad()) return 1; ErrSetMessageLevel(SEV_WARNING); /* if (myargs[ARG_FORCE_OLD].intvalue == 0 && myargs[ARG_OUTTYPE].intvalue > 1 && myargs[ARG_GILIST].strvalue == NULL) use_new_engine = readdb_use_new_blast(myargs[ARG_DB].strvalue); if (myargs[ARG_MASKEDQUERY].strvalue) use_new_engine = FALSE; */ /*if (use_new_engine) return Main_new(); else */ return Main_old(); }
Int2 Main(void) { AsnIoPtr aip; SeqEntryPtr sep; BytePtr buf; Uint2 size = 32000, count; AsnIoMemPtr aimp; /* check command line arguments */ if ( ! GetArgs("testmem",NUMARG, myargs)) return 1; /* load the sequence alphabets */ /* (and sequence parse trees) */ if (! SeqEntryLoad()) ErrShow(); /* open the ASN.1 input file in the right mode */ if ((aip = AsnIoOpen (myargs[0].strvalue, myargs[1].intvalue?"rb":"r")) == NULL) ErrShow(); sep = SeqEntryAsnRead(aip, NULL); /* read the entry */ AsnIoClose(aip); SeqEntryPack(sep); /* pack it */ buf = MemNew(size); /* allocate a buffer */ aimp = AsnIoMemOpen("wb", buf, size); /* open to write asn1 to it */ SeqEntryAsnWrite(sep, aimp->aip, NULL); /* write it */ AsnIoFlush(aimp->aip); /* flush it */ count = aimp->count; /* record how many bytes in it */ AsnIoMemClose(aimp); /* close it */ SeqEntryFree(sep); /* release the object */ aimp = AsnIoMemOpen("rb", buf, count); /* open to read from buffer */ sep = SeqEntryAsnRead(aimp->aip, NULL); /* read it */ AsnIoMemClose(aimp); /* close it */ MemFree(buf); /* free the buffer */ /* open the output file */ aip = AsnIoOpen (myargs[2].strvalue, "w"); SeqEntryAsnWrite(sep, aip, NULL); /* print it */ AsnIoClose(aip); SeqEntryFree(sep); return(0); }
/***************************************************************************** * * Main program loop to read, process, write SeqEntrys * *****************************************************************************/ Int2 Main(void) { AsnIoPtr aipout=NULL, aipin; AsnTypePtr atp, atp_inst; AsnModulePtr amp; DataVal dv; CharPtr ftype; BioseqPtr bsp; /* check command line arguments */ if ( ! GetArgs("asn2xml 1.0",NUMARG, myargs)) return 1; /* load the sequence alphabets */ /* (and sequence parse trees) */ if (! SeqEntryLoad()) ErrShow(); if (! SubmitAsnLoad()) ErrShow(); if (! SeqCodeSetLoad()) ErrShow(); /* get pointer to all loaded ASN.1 modules */ amp = AsnAllModPtr(); if (amp == NULL) { ErrShow(); return 1; } if (myargs[1].intvalue) atp = AsnFind("Seq-entry"); else if (myargs[2].intvalue) atp = AsnFind("Seq-submit"); else atp = AsnFind("Bioseq-set"); /* get the initial type pointers */ if (atp == NULL) { ErrShow(); return 1; } atp_inst = AsnFind("Bioseq.inst"); if (atp_inst == NULL) { ErrShow(); return 1; } /* open the ASN.1 input file in the right mode */ if ((aipin = AsnIoOpen (myargs[0].strvalue, myargs[3].intvalue?"rb":"r")) == NULL) { ErrPostEx(SEV_ERROR,0,0, "Can't open %s", myargs[0].strvalue); ErrShow(); return 1; } /* open the ASN.1 output file in the right mode */ if (myargs[4].strvalue != NULL) /* output desired? */ { ftype = "wx"; if ((aipout = AsnIoOpen (myargs[4].strvalue, ftype)) == NULL) { ErrPostEx(SEV_ERROR,0,0, "Can't open %s", myargs[4].strvalue); ErrShow(); return 1; } } /* log errors instead of die */ if (myargs[5].strvalue != NULL) { if (! ErrSetLog (myargs[5].strvalue)) { ErrShow(); return 1; } else ErrSetOpts (ERR_CONTINUE, ERR_LOG_ON); } while ((atp = AsnReadId(aipin, amp, atp)) != NULL) { if (atp == atp_inst) /* need object loader convert */ { bsp = BioseqNew(); /* need newly initialized bsp */ BioseqInstAsnRead(bsp, aipin, atp); BioseqInstAsnWrite(bsp, aipout, atp); bsp = BioseqFree(bsp); } else { AsnReadVal(aipin, atp, &dv); /* read it */ AsnWrite(aipout, atp, &dv); /* write it */ AsnKillValue(atp, &dv); /* free it */ } } AsnIoClose(aipin); AsnIoClose(aipout); return(0); }
Int2 Main(void) { AsnIoPtr aip; FILE * aa = NULL, * na = NULL, * ql = NULL; SeqEntryPtr sep; SeqSubmitPtr ssp; AsnTypePtr atp, atp2; AsnModulePtr amp; Uint1 group_segs = 0; Boolean limit_to_genbank, make_dna, make_protein, make_quality, far_quality, do_it; /* check command line arguments */ if ( ! GetArgs("asn2fast",NUMARG, myargs)) return 1; /* load the sequence alphabets */ /* (and sequence parse trees) */ if (! SeqEntryLoad()) { ErrShow(); return 1; } /* get pointer to all loaded ASN.1 modules */ amp = AsnAllModPtr(); if (amp == NULL) { ErrShow(); return 1; } if (myargs[11].intvalue) { if (! SubmitAsnLoad()) Message(MSG_FATAL, "Unable to load parse trees."); atp2 = AsnFind("Seq-submit"); if (atp2 == NULL) Message(MSG_FATAL, "Unable to find Seq-submit"); atp = AsnFind("Seq-submit"); if (atp == NULL) Message(MSG_FATAL, "Unable to find Seq-submit"); } else { atp = AsnFind("Bioseq-set"); /* get the initial type pointers */ if (atp == NULL) { ErrShow(); return 1; } atp2 = AsnFind("Bioseq-set.seq-set.E"); if (atp2 == NULL) { ErrShow(); return 1; } } make_protein = (Boolean)(myargs[7].intvalue); make_dna = (Boolean)(myargs[8].intvalue); make_quality = (Boolean)(myargs[12].intvalue); far_quality = (Boolean)(myargs[14].intvalue); /* open the ASN.1 input file in the right mode */ if ((aip = AsnIoOpen (myargs[0].strvalue, myargs[2].intvalue?"rb":"r")) == NULL) { ErrShow(); return 1; } /* open the output file */ if ((myargs[3].strvalue != NULL) && (make_protein)) { if ( (aa = FileOpen (myargs[3].strvalue, "w")) == NULL) { ErrShow(); return 1; } } if ((myargs[4].strvalue != NULL) && (make_dna)) { if ( (na = FileOpen (myargs[4].strvalue, "w")) == NULL) { ErrShow(); return 1; } } if ((myargs[13].strvalue != NULL) && (make_quality)) { if ( (ql = FileOpen (myargs[13].strvalue, "w")) == NULL) { ErrShow(); return 1; } } /* log errors instead of die */ if (myargs[5].strvalue != NULL) { if (! ErrSetLog (myargs[5].strvalue)) ErrShow(); else ErrSetOpts (ERR_CONTINUE, ERR_LOG_ON); } if (myargs[6].intvalue) /* combine segmented seqs */ { group_segs = 1; if (myargs[10].intvalue) group_segs = 3; /* and instantiate virtuals */ } limit_to_genbank = (Boolean)(myargs[9].intvalue); if (myargs [15].intvalue) { ID1BioseqFetchEnable ("asn2fast", FALSE); } if (myargs [16].intvalue) { LocalSeqFetchInit (FALSE); } if ( myargs[1].intvalue) /* read one Seq-entry */ { sep = SeqEntryAsnRead(aip, NULL); do_it = TRUE; if (limit_to_genbank) do_it = CheckIsGenBank(sep); if (do_it) { if (make_protein) SeqEntrysToFasta(sep, aa, FALSE, group_segs); if (make_dna) SeqEntrysToFasta(sep, na, TRUE, group_segs); if (make_quality) { if (far_quality) { SeqEntryExplore (sep, (Pointer) ql, PrintFarQualScores); } else { SeqEntryExplore (sep, (Pointer) ql, PrintQualScores); } } } SeqEntryFree(sep); } else if ( myargs[11].intvalue) /* read Seq-submit's */ { while ((atp = AsnReadId(aip, amp, atp)) != NULL) { if (atp == atp2) /* top level Seq-entry */ { ssp = SeqSubmitAsnRead(aip, atp); if (ssp->datatype == 1) { sep = (SeqEntryPtr) ssp->data; do_it = TRUE; if (limit_to_genbank) do_it = CheckIsGenBank(sep); if (do_it) { if (make_protein) SeqEntrysToFasta(sep, aa, FALSE, group_segs); if (make_dna) SeqEntrysToFasta(sep, na, TRUE, group_segs); if (make_quality) { if (far_quality) { SeqEntryExplore (sep, (Pointer) ql, PrintFarQualScores); } else { SeqEntryExplore (sep, (Pointer) ql, PrintQualScores); } } } } SeqSubmitFree(ssp); } else { AsnReadVal(aip, atp, NULL); } } } else /* read Seq-entry's from a Bioseq-set */ { while ((atp = AsnReadId(aip, amp, atp)) != NULL) { if (atp == atp2) /* top level Seq-entry */ { sep = SeqEntryAsnRead(aip, atp); do_it = TRUE; if (limit_to_genbank) do_it = CheckIsGenBank(sep); if (do_it) { if (make_protein) SeqEntrysToFasta(sep, aa, FALSE, group_segs); if (make_dna) SeqEntrysToFasta(sep, na, TRUE, group_segs); if (make_quality) { if (far_quality) { SeqEntryExplore (sep, (Pointer) ql, PrintFarQualScores); } else { SeqEntryExplore (sep, (Pointer) ql, PrintQualScores); } } } SeqEntryFree(sep); } else { AsnReadVal(aip, atp, NULL); } } } AsnIoClose(aip); if (make_protein) FileClose(aa); if (make_dna) FileClose(na); if (make_quality) FileClose (ql); if (myargs [16].intvalue) { LocalSeqFetchDisable (); } if (myargs [15].intvalue) { ID1BioseqFetchDisable (); } return(0); }
/***************************************************************************** * * This is the main program. * It reads command line or initial dialogue arguments * It initializes parse trees, entrez * It makes a list of the relevant files to search * It then calls ProcessFileList to open each file and process it * *****************************************************************************/ Int2 Main (void) { Char div [8]; FileListPtr flp = NULL; FILE *fp; Int2 i; Boolean is_network, did_init=FALSE; FileListPtr next; CharPtr outputfile; if (! GetArgs ("CdScan", NUMARGS, myargs)) /* get input args */ goto ret; /* process input args */ if (myargs[0].intvalue == 1) is_na = TRUE; /* scan nucleic acids */ else is_na = FALSE; /* scan proteins */ format = (Int2)(myargs[1].intvalue); is_custom = (Boolean)(myargs[2].intvalue); if (myargs[3].intvalue) /* show progress */ { pmon = MonitorStrNew("CdScan", 40); } outputfile = myargs[4].strvalue; /* output file name */ if (pmon != NULL) MonitorStrValue(pmon, "Reading Parse Trees"); if (! SeqEntryLoad() || ! SubmitAsnLoad()) /* read ASN.1 parse trees */ { Message(MSG_ERROR, "Can't open parse trees"); goto ret; } if (! PrintTemplateSetLoad ("asn2ff.prt")) { Message(MSG_ERROR, "Can't load print templates"); goto ret; } if (pmon != NULL) MonitorStrValue(pmon, "Initializing Entrez"); if (! EntrezInit ("cdscan", FALSE, &is_network)) /* init Entrez */ { Message(MSG_ERROR, "Can't initialize Entrez"); goto ret; } did_init = TRUE; if (is_network) { Message (MSG_ERROR, "Network service does not allow scanning"); goto ret; } if (pmon != NULL) MonitorStrValue(pmon, "Building File List"); eip = EntrezGetInfo (); /* set up the file lists */ if ((eip == NULL) || (eip->div_info == NULL)) { Message(MSG_ERROR, "Can't find Entrez file info"); goto ret; } flp = FileListNew (NULL, INT2_MIN, NULL, NULL); if (flp == NULL) { Message(MSG_ERROR, "Can't allocate file list"); goto ret; } div_info = eip->div_info; for (i = 0; i < eip->div_count; i++) { StringNCpy (div, div_info [i].tag, sizeof (div) - 1); if (! is_na) { CdEnumFiles (CdDir_rec, TYP_AA, div, EnumerateFiles, &flp); } else { CdEnumFiles (CdDir_rec, TYP_NT, div, EnumerateFiles, &flp); } } fp = FileOpen (outputfile, "w"); /* test that we can open output file */ if (fp == NULL) { Message(MSG_ERROR, "Can't open [%s]", outputfile); goto ret; } FileClose (fp); /* will be reopened for each input file */ ProcessFileList (flp, outputfile); /* process the file list */ ret: /* clean up */ if (pmon != NULL) /* close the progress monitor */ MonitorFree(pmon); if (did_init) EntrezFini(); /* close entrez */ while (flp != NULL) /* free file list */ { next = flp->next; MemFree (flp->fdir); MemFree (flp->fname); MemFree (flp); flp = next; } return 0; }
Int2 Main(void) { WWWInfoPtr info; WWWErrorCode error; BEDataPtr pBdata; Int4 count; Uint4 *ids; Char tmp[512]; if((error = WWWReadPosting(&info)) != WWWErrOk) { ErrPostEx(SEV_FATAL, 88, 0, "Error in processing WWW request"); return 1; } if(WWWGetMethod(info) == COMMAND_LINE) { WWWInfoFree(info); if((pBdata = BEMakeCLParam()) == NULL) return 1; } else { if(!ErrSetLogfile (QSRV_LOGFILE_STD_NAME, ELOG_APPEND)) return 1; if((pBdata = BEMakeWWWParam(info)) == NULL) { printf("Content-type: text/html\n\n"); printf("QSRV_STATUS 802 Invalid input parameters <PRE><BR>\n"); fflush(stdout); ErrPostEx(SEV_ERROR, 88, 0, "Error in reading parameters. " "Please check, that query string was set\n"); return 1; } } if(!pBdata->commandline) { if(pBdata->savetodisk) printf("Content-type: chemical/seq-%s-genbank\n\n", pBdata->database == 0 ? "na" : "aa"); else { printf("Content-type: text/html\n\n"); printf("<HTML><HEADER><TITLE>Batch Entrez results" "</TITLE></HEADER><PRE>\n"); } } if (! ID1BioseqFetchEnable("Nbatch", TRUE)) { printf("Cannot initialize ID1\n"); return 1; } if(pBdata->html) { init_www(); /* initializing WWW mode */ head_tail_ff(NULL, BatchHead, BatchTail); } SeqEntryLoad(); switch(pBdata->request_type) { case REQ_DEFAULT: if(pBdata->uids == NULL) { count = BEGetUidsFromQuery(pBdata->query, &ids, pBdata->database == 0, /* Nucleotide ? */ FALSE); } else { count = BE_ReadIds(pBdata, &ids); } break; case REQ_ADVANCED_QUERY: case REQ_ORGANISM: count = BEGetUidsFromQuery(pBdata->query, &ids, pBdata->database == 0, /* Nucleotide ? */ FALSE); break; case REQ_LIST_OF_GIS: count = BE_ReadIds(pBdata, &ids); break; } pBdata->count = count; QSRVWriteLogInfo(pBdata); if(count < 0) { if(pBdata->commandline) ErrPostEx(SEV_ERROR, 0, count, "Error in searching the database"); else printf("QSRV_STATUS %d Error in searching database\n", count); return 1; } if(count == 0) { if(pBdata->commandline) ErrPostEx(SEV_INFO, 0,0, "No entries found"); else printf("QSRV_STATUS 901 OK No entries found\n", count); return 1; } if((count > 20000 && pBdata->format == F_GEN) || (count > 100000 && pBdata->format != F_GILIST)) { if(pBdata->commandline) ErrPostEx(SEV_WARNING, 0,0, "Number of sequences %d exceed limit", count); else printf("QSRV_STATUS 803 Error Number of sequences %d " "exceed limit\n", count); pBdata->format = F_GILIST; } if(!pBdata->noheader && !pBdata->commandline) printf("QSRV_STATUS 900 OK: %d entr%s found <PRE><BR>\n", count, count == 1? "y" : "ies"); fflush(stdout); /* Printing results */ BEPrintIds(pBdata, ids, count); /* Clearing memory */ MemFree(ids); BEFreeCLParam(pBdata); return 0; }
char *readASNSeq(const short whichEntry, const char *filename, const long skiplines, const short format, /* note: this is kASNseqentry or kASNseqset */ long *seqlen, short *nseq, short *error, char **seqid ) { AsnIoPtr aip = NULL; SeqEntryPtr the_set; AsnTypePtr atp, atp2; AsnModulePtr amp; Boolean inIsBinary= FALSE; /* damn, why can't asn routines test this? */ char *seq, stemp[200]; int i, count; *seqlen= 0; *nseq= 0; *error= 0; seq= NULL; /*fprintf(stderr,"readASNseq: SeqEntryLoad\n");*/ /* asn dictionary setups */ if (! SeqEntryLoad()) goto errxit; /* sequence alphabets (and sequence parse trees) */ amp = AsnAllModPtr(); /* get pointer to all loaded ASN.1 modules */ if (amp == NULL) goto errxit; atp = AsnFind("Bioseq-set"); /* get the initial type pointers */ if (atp == NULL) goto errxit; atp2 = AsnFind("Bioseq-set.seq-set.E"); if (atp2 == NULL) goto errxit; /* open the ASN.1 input file in the right mode */ /*fprintf(stderr,"readASNseq: AsnIoOpen(%s)\n", filename);*/ if ((aip = AsnIoOpen(filename, inIsBinary?"rb":"r")) == NULL) goto errxit; for (i=0; i<skiplines; i++) fgets( stemp, 255, aip->fp); /* this may mess up asn routines... */ if (! ErrSetLog ("stderr")) goto errxit; else ErrSetOpts(ERR_CONTINUE, ERR_LOG_ON); /*?? log errors instead of die */ seq= NULL; if (format == kASNseqentry) { /* read one Seq-entry */ /*fprintf(stderr,"readASNseq: SeqEntryAsnRead\n");*/ the_set = SeqEntryAsnRead(aip, NULL); SeqEntryToRaw(the_set, false, whichEntry, nseq, &seq, seqid, seqlen); SeqEntryFree(the_set); goto goodexit; } else { /* read Seq-entry's from a Bioseq-set */ count = 0; /*fprintf(stderr,"readASNseq: AsnReadId\n");*/ while ((atp = AsnReadId(aip, amp, atp)) != NULL) { if (atp == atp2) { /* top level Seq-entry */ the_set = SeqEntryAsnRead(aip, atp); SeqEntryToRaw(the_set, false, whichEntry, nseq, &seq, seqid, seqlen); SeqEntryFree(the_set); if (*nseq >= whichEntry) goto goodexit; } else AsnReadVal(aip, atp, NULL); count++; } } goodexit: AsnIoClose(aip); *error= 0; return seq; errxit: AsnIoClose(aip); *error= eASNerr; if (seq) free(seq); return NULL; }
Int2 Main(void) { AsnIoPtr aip; SeqEntryPtr sep; BioseqPtr PNTR seqlist; Int4 seqnum, i, numseg, lens[10], j; Int2 ctr; SeqPortPtr spp; Uint1 residue; FILE* fp; CharPtr title; Char buffer[101]; MonitorPtr mon; /* check command line arguments */ if ( ! GetArgs("SeqTest",NUMARG, myargs)) return 1; mon = MonitorStrNew("SeqTest", 40); SetProgMon(StdProgMon, (Pointer)mon); /* ** Load SeqEntry object loader and sequence alphabets */ if (! SeqEntryLoad()) { Message(MSG_ERROR, "SeqEntryLoad failed"); return 1; } /* ** Use the file "example.prt" as the ASN I/O stream. This file ** can be found in the ncbi/demo. It is in ASN.1 Print Value format. */ if ((aip = AsnIoOpen(myargs[0].strvalue, "r")) == NULL) return 1; /* ** Write the output to "seqtest.out". */ fp = FileOpen(myargs[1].strvalue, "w"); fprintf(fp, "Sequence summary:\n\n"); /* ** Read in the whole entry into the Sequence Entry Pointer, sep. ** Close the ASN stream, which in turn closes the input file. */ sep = SeqEntryAsnRead(aip, NULL); aip = AsnIoClose(aip); mon = MonitorFree(mon); SetProgMon(NULL, NULL); /* ** Determine how many Bioseqs are in this SeqEntry. Allocate ** enough memory to hold a list of pointer to all of these ** Bioseqs. Invoke an Explore function to "visit"each Bioseq. ** We are allowed to pass one pointer for use by the exploring ** function, in this case, "BuildList". */ seqnum = BioseqCount(sep); seqlist = MemNew((size_t)(seqnum * sizeof(BioseqPtr))); BioseqExplore(sep, (Pointer) seqlist, BuildList); /* ** For each Bioseq in the SeqEntry write out it's title ** len, number of gaps, and number of segments. Write out ** the length of each segment, up to 10. */ for(i = 0; i < seqnum; i++) { numseg = BioseqCountSegs(seqlist[i]); title = BioseqGetTitle(seqlist[i]); FilePuts((VoidPtr)title, fp); FilePuts("\n", fp); fprintf(fp, "len=%ld gaps=%ld segs=%ld\n", BioseqGetLen(seqlist[i]), BioseqGetGaps(seqlist[i]), numseg); if ((numseg > 1) && (numseg <= 10)) { BioseqGetSegLens (seqlist[i], lens); for (j = 0; j < numseg; j++) fprintf(fp, " len = %ld\n", lens[j]); } FilePuts("\n", fp); } spp = SeqPortNew(seqlist[0], 0, -1, 0, Seq_code_iupacna); if (spp == NULL) Message(MSG_ERROR, "fail on SeqPortNew"); fprintf(fp, "SeqPort: plus strand with SeqPortGetResidue\n\n"); i = 0; while ((residue = SeqPortGetResidue(spp)) != SEQPORT_EOF) { if (! IS_residue(residue)) { buffer[i] = '\0'; fprintf(fp, "%s\n", buffer); i = 0; switch (residue) { case SEQPORT_VIRT: fprintf(fp, "[Gap]\n"); break; case SEQPORT_EOS: fprintf(fp, "[EOS]\n"); break; default: fprintf(fp, "[Invalid Residue]\n"); break; } } else { buffer[i] = residue; i++; if (i == 60) { buffer[i] = '\0'; fprintf(fp, "%s\n", buffer); i = 0; } } } if (i) { buffer[i] = '\0'; fprintf(fp, "%s\n", buffer); } fprintf(fp, "[EOF]\n"); SeqPortFree(spp); fprintf(fp, "\nSeqPort on minus with SeqPortRead\n\n"); spp = SeqPortNew(seqlist[0], 0, -1, Seq_strand_minus, Seq_code_iupacna); if (spp == NULL) Message(MSG_ERROR, "fail on SeqPortNew"); do { ctr = SeqPortRead(spp, (Uint1Ptr)buffer, 60); if (ctr > 0) { buffer[ctr] = '\0'; fprintf(fp, "%s\n", buffer); } else { ctr *= -1; switch (ctr) { case SEQPORT_VIRT: fprintf(fp, "[Gap]\n"); break; case SEQPORT_EOS: fprintf(fp, "[EOS]\n"); break; case SEQPORT_EOF: fprintf(fp, "[EOF]\n"); break; default: fprintf(fp, "[Invalid Residue]\n"); break; } } } while (ctr != SEQPORT_EOF); SeqPortFree(spp); /* ** Write out the nucleic acid sequences in this SeqEntry */ fprintf(fp, "\nNucleic Acids in FASTA format:\n\n"); SeqEntryToFasta(sep, fp, TRUE); /* ** Write out the protein sequences in this SeqEntry. */ fprintf(fp, "\nProteins in FASTA format:\n\n"); SeqEntryToFasta(sep, fp, FALSE); /* ** Close the output file and free up allocated space. */ fclose(fp); MemFree(seqlist); SeqEntryFree(sep); return 0; }