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 () { Int2 orient; CharPtr txt=NULL; Boolean Bool=TRUE; ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return -1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! FeatDefSetLoad ()) { Message (MSG_FATAL, "FeatDefSetLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } if (!ID1BioseqFetchEnable("DotMatrix", FALSE)) { ErrPostEx(SEV_FATAL, 1, 0, "Bad sequence offset values"); return -1; } LocalSeqFetchInit (FALSE); DOT_StartupWindow(); LocalSeqFetchDisable (); ID1BioseqFetchDisable(); }
Int2 Main (void) { AsnIoPtr aip; Boolean convertgis; Boolean extractmrnas; CharPtr infile, outfile; SeqEntryPtr sep; /* standard setup */ ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); /* finish resolving internal connections in ASN.1 parse tables */ if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! FeatDefSetLoad ()) { Message (MSG_FATAL, "FeatDefSetLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } /* process command line arguments */ if (! GetArgs ("gi2accn", sizeof (myargs) / sizeof (Args), myargs)) { return 0; } infile = (CharPtr) myargs [i_argInputFile].strvalue; outfile = (CharPtr) myargs [o_argOutputFile].strvalue; convertgis = (Boolean) myargs [c_argConvertGIs].intvalue; extractmrnas = (Boolean) myargs [x_argExtractMrnas].intvalue; aip = AsnIoOpen (infile, "r"); if (aip == NULL) { Message (MSG_FATAL, "AsnIoOpen input file failed"); return 1; } sep = SeqEntryAsnRead (aip, NULL); AsnIoClose (aip); if (sep == NULL) { Message (MSG_FATAL, "SeqEntryAsnRead failed"); return 1; } PubSeqFetchEnable (); LookupFarSeqIDs (sep, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE); /* Extract mRNA hits from BLAST against nr */ if (extractmrnas) { VisitAnnotsInSep (sep, NULL, FindBlastNR); DeleteMarkedObjects (0, OBJ_SEQENTRY, (Pointer) sep); } /* convert gi numbers to accession.version */ if (convertgis) { VisitAlignmentsInSep (sep, NULL, UpdateAligns); } PubSeqFetchDisable (); BasicSeqEntryCleanup (sep); aip = AsnIoOpen (outfile, "w"); if (aip == NULL) { Message (MSG_FATAL, "AsnIoOpen output file failed"); return 1; } SeqEntryAsnWrite (sep, aip, NULL); AsnIoClose (aip); return 0; }
Int2 Main (void) { AsnIoPtr aop = NULL; AsnModulePtr amp; AsnTypePtr atp_bss, atp_ss, atp_se; BioseqSet bss; FILE *fp; ValNodePtr head, vnp; Char path [PATH_MAX]; CharPtr progname, str, subfile; ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } MemSet ((Pointer) &bss, 0, sizeof (BioseqSet)); amp = AsnAllModPtr (); if (amp == NULL) { Message (MSG_FATAL, "Unable to load AsnAllModPtr"); return 1; } atp_bss = AsnFind ("Bioseq-set"); if (atp_bss == NULL) { Message (MSG_FATAL, "Unable to find ASN.1 type Bioseq-set"); return 1; } atp_ss = AsnFind ("Bioseq-set.seq-set"); if (atp_ss == NULL) { Message (MSG_FATAL, "Unable to find ASN.1 type Bioseq-set.seq-set"); return 1; } atp_se = AsnFind ("Bioseq-set.seq-set.E"); if (atp_se == NULL) { Message (MSG_FATAL, "Unable to find ASN.1 type Bioseq-set.seq-set.E"); return 1; } ProgramPath (path, sizeof (path)); progname = StringRChr (path, DIRDELIMCHR); if (progname != NULL) { progname++; } else { progname = "idcleanscan"; } if (! GetArgs (progname, sizeof (myargs) / sizeof (Args), myargs)) { return 0; } fp = FileOpen (myargs [o_argOutputFile].strvalue, "a"); if (fp == NULL) { Message (MSG_FATAL, "FileOpen failed"); return 1; } if (StringHasNoText (myargs [p_argInputPath].strvalue)) { str = myargs [i_argInputFile].strvalue; if (! StringHasNoText (str)) { DoReleaseFile (str, myargs [b_argBinaryFile].intvalue, myargs [c_argCompressed].intvalue, fp, aop, NULL); } } else { head = DirCatalog (myargs [p_argInputPath].strvalue); if (! StringHasNoText (myargs [s_argSubset].strvalue)) { aop = AsnIoOpen (myargs [s_argSubset].strvalue, /* "wb" */ "w"); AsnOpenStruct (aop, atp_bss, (Pointer) &bss); AsnOpenStruct (aop, atp_ss, (Pointer) bss.seq_set); /* av.intvalue = BioseqseqSet_class_genbank; AsnWrite (aop, atp_cls, &av); */ } for (vnp = head; vnp != NULL; vnp = vnp->next) { if (vnp->choice == 0) { str = (CharPtr) vnp->data.ptrvalue; if (! StringHasNoText (str)) { subfile = myargs [x_argFileSelect].strvalue; if (StringHasNoText (subfile) || StringStr (str, subfile) != NULL) { #ifdef OS_UNIX /* printf ("%s\n", str); */ #endif DoReleaseFile (str, myargs [b_argBinaryFile].intvalue, myargs [c_argCompressed].intvalue, fp, aop, atp_se); } } } } if (aop != NULL) { AsnCloseStruct (aop, atp_ss, (Pointer) bss.seq_set); AsnCloseStruct (aop, atp_bss, (Pointer) &bss); AsnIoClose (aop); } ValNodeFreeData (head); } FileClose (fp); return 0; }
Int2 Main (void) { CharPtr base, directory, organism, ptr; Boolean altstart, findorf, flatfile, validate; ValNodePtr head, vnp; ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } if (! FeatDefSetLoad ()) { Message (MSG_FATAL, "FeatDefSetLoad failed"); return 1; } if (! GetArgs ("sgd2asn", sizeof (myargs) / sizeof (Args), myargs)) { return 0; } directory = (CharPtr) myargs [0].strvalue; base = (CharPtr) myargs [1].strvalue; organism = (CharPtr) myargs [2].strvalue; findorf = (Boolean) myargs [3].intvalue; altstart = (Boolean) myargs [4].intvalue; validate = (Boolean) myargs [5].intvalue; flatfile = (Boolean) myargs [6].intvalue; if (! StringHasNoText (base)) { ptr = StringStr (base, ".fsa"); if (ptr != NULL) { *ptr = '\0'; ProcessOneRecord (directory, base, organism, findorf, altstart, validate, flatfile); } } else { head = DirCatalog (directory); for (vnp = head; vnp != NULL; vnp = vnp->next) { if (vnp->choice == 0) { base = (CharPtr) vnp->data.ptrvalue; if (! StringHasNoText (base)) { ptr = StringStr (base, ".fsa"); if (ptr != NULL) { *ptr = '\0'; ProcessOneRecord (directory, base, organism, findorf, altstart, validate, flatfile); } } } } ValNodeFreeData (head); } return 0; }
Int2 Main(void) { Char app [64]; Int4 rval = 0; CharPtr id_file; ValNodePtr fetch_list = NULL; ValNodePtr field_list = NULL; ValNodePtr table; Boolean meta_mode = FALSE; FILE *fp; /* standard setup */ ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); /* finish resolving internal connections in ASN.1 parse tables */ if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! FeatDefSetLoad ()) { Message (MSG_FATAL, "FeatDefSetLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } #ifdef INTERNAL_NCBI_TBL_CHK SmartFetchEnable (); TPASmartFetchEnable (); if (! PUBSEQBioseqFetchEnable ("tbl_chk", FALSE)) { Message (MSG_POSTERR, "PUBSEQBioseqFetchEnable failed"); return 1; } #else PubSeqFetchEnable (); #endif /* process command line arguments */ sprintf (app, "tbl_chk %s", TBL_CHK_APPLICATION); if (! GetArgs (app, sizeof (myargs) / sizeof (Args), myargs)) { return 0; } id_file = (CharPtr) myargs [i_argInputFile].strvalue; debug_mode = (Boolean) myargs [D_argDebugMode].intvalue; meta_mode = (Boolean) myargs [m_argMetaMode].intvalue; fp = FileOpen (id_file, "r"); if (fp == NULL) { Message (MSG_ERROR, "Unable to open %s", id_file); return 1; } table = ReadTabTableFromFile (fp); FileClose (fp); if (table == NULL || table->next == NULL) { Message (MSG_ERROR, "Table must have at least two rows, one header and one data"); return 1; } field_list = GetFieldListFromHeader(table->data.ptrvalue); if (field_list == NULL) { Message (MSG_ERROR, "Unable to read table header"); table = FreeTabTable (table); return 1; } fetch_list = FetchItemListFromTable (table); MakeFetchItemIndex(fetch_list); fp = FileOpen ((CharPtr) myargs [o_argOutputFile].strvalue, "w"); if (fp == NULL) { Message (MSG_ERROR, "Unable to open %s", (CharPtr) myargs [o_argOutputFile].strvalue); rval = 1; } else { if (meta_mode) { fprintf (fp, "Accession\tField\tOld Value\tNew Value\n"); } ProcessBioseqsWithCaching (fetch_list, field_list, table, meta_mode, fp); } FileClose (fp); field_list = FieldTypeListFree (field_list); fetch_list = FetchItemListFree (fetch_list); MakeFetchItemIndex(NULL); return rval; }
Int2 Main (void) { EntrezInfoPtr eip; PaneL p; RecT r; Char str [16]; Int2 val; WindoW w; /* #if defined(WIN16) #else PRGD prgdDict; #endif */ ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); ProcessUpdatesFirst (FALSE); /* if (! GetAppParam ("NCBI", "NCBI", NULL, NULL, str, sizeof (str) - 1)) { if (Message (MSG_YN, configMessage) == ANS_YES) { ShowNetConfigForm (ConfigFormActivated, ConfigFormMessage, ConfigAccepted, ConfigCancelled); ProcessEvents (); return 0; } else { Message (MSG_FATAL, "Entrez cannot run without ncbi configuration file"); } return 0; } if (! GetAppParam ("NCBI", "NCBI", NULL, NULL, str, sizeof (str) - 1)) { Message (MSG_FATAL, "Entrez cannot find ncbi configuration file"); return 0; } */ UseLocalAsnloadDataAndErrMsg (); SetupAppProperties (); SetupCommonFonts (); entrezRelease [0] = '\0'; sprintf (entrezVersion, "Entrez Application Version %s", ENTREZ_APP_VERSION); w = FixedWindow (-50, -33, -10, -10, "Entrez", NULL); p = SimplePanel (w, AboutBoxWidth (), 14 * stdLineHeight, DrawAbout); Show (w); #ifdef WIN_MOTIF Select (w); ObjectRect (p, &r); Select (p); InsetRect (&r, 3, 3); InvalRect (&r); #endif Update (); WatchCursor (); SetTitle (w, "Finding Entrez Data"); if (! EntrezBioseqFetchEnable ("Entrez", TRUE)) { ArrowCursor (); /* Message (MSG_FATAL, "Unable to connect to Entrez databases"); */ if (Message (MSG_YN, configMessage) == ANS_YES) { ShowNetConfigForm (ConfigFormActivated, ConfigFormMessage, ConfigAccepted, ConfigCancelled, NULL, TRUE); ProcessEvents (); return 0; } else { Message (MSG_FATAL, "Entrez cannot run connection to the data server"); } return 0; } ID1BioseqFetchEnable ("Entrez", TRUE); LocalSeqFetchInit (FALSE); #ifdef WIN_MAC SetDeactivate (NULL, MacDeactProc); SetupMacMenus (); #endif eip = EntrezGetInfo (); if (eip != NULL) { /* { AsnIoPtr aip; aip = AsnIoOpen ("eip", "w"); if (aip != NULL) { EntrezInfoAsnWrite (eip, aip, NULL); AsnIoClose (aip); } } */ sprintf (entrezRelease, "Entrez Data Release %d.%d", (int) eip->version, (int) eip->issue); Select (p); ObjectRect (p, &r); InsetRect (&r, 3, 3); InvalRect (&r); Update (); } SetTitle (w, "Loading parse tables"); if (! AllObjLoad ()) { ArrowCursor (); Message (MSG_FATAL, "AllObjLoad failed"); return 0; } if (! SubmitAsnLoad ()) { ArrowCursor (); Message (MSG_FATAL, "SubmitAsnLoad failed"); return 0; } SetTitle (w, "Loading print templates"); if (! PrintTemplateSetLoad ("objprt.prt")) { ArrowCursor (); Message (MSG_FATAL, "PrintTemplateSetLoad objprt.prt failed"); return 0; } if (! PrintTemplateSetLoad ("asn2ff.prt")) { ArrowCursor (); Message (MSG_FATAL, "PrintTemplateSetLoad asn2ff.prt failed"); return 0; } /* if (! PrintTemplateSetLoad ("makerpt.prt")) { ArrowCursor (); Message (MSG_FATAL, "PrintTemplateSetLoad makerpt.prt failed"); return 0; } */ SetTitle (w, "Loading sequence alphabet converter"); if (! SeqCodeSetLoad ()) { ArrowCursor (); Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 0; } SetTitle (w, "Loading feature definitions"); if (! FeatDefSetLoad ()) { ArrowCursor (); Message (MSG_FATAL, "FeatDefSetLoad failed"); return 0; } if (! SetupPrintOptions ()) { ArrowCursor (); Message (MSG_FATAL, "StdPrintOptionsNew failed"); return 0; } /* #ifndef WIN16 SetTitle (w, "Loading structure dictionary"); if (OpenMMDBAPI ((POWER_VIEW ^ FETCH_ENTREZ), NULL)) { prgdDict = GetPRGDDictionary (); Cn3DWin_Entrez(NULL, TRUE); } #endif */ SetTitle (w, "Creating menus"); REGISTER_MEDLINE_VIEW; REGISTER_NEW_SEQENTRY_VIEW; VSMFileInit (); VSeqMgrInit (FALSE); SetTitle (w, "Creating window"); InitMuskStyles (); if (GetEntrezAppParam ("PREFERENCES", "DEFAULTSTYLE", "", str, sizeof (str))) { if (StrToInt (str, &val) && val >= 0) { SetMuskCurrentSt (GetMuskStyleName (val)); } } /* SetTitle (w, "Creating help window"); if (helpForm == NULL) { helpForm = CreateHelpForm (-95, -5, "Entrez Help", "entrez.hlp", HideHelpForm, HelpActivateProc); } */ SetTitle (w, "Creating initial window"); termListForm = CreateTermListForm (-70, -70, "Entrez1 Query", TermSelectionActivateProc, TermSelectionFormMessage); Remove (w); ArrowCursor (); if (termListForm != NULL) { Show (termListForm); Select (termListForm); Update (); docSumForm = CreateDocSumForm (-90, -10, "Entrez1 Document", DocumentSummaryActivateProc, DocumentSummaryFormMessage); UseDelayedNeighbor (docSumForm, TRUE); if (docSumForm != NULL) { ProcessEvents (); } else { Message (MSG_FATAL, "Unable to create document window"); } } else { Message (MSG_FATAL, "Unable to create term list window"); } WatchCursor (); val = GetMuskCurrentSt (); if (val < 0) { val = 0; } if (val >= GetMuskTotalSt ()) { val = 0; } if (val > 0) { sprintf (str, "%d", (int) val); SetEntrezAppParam ("PREFERENCES", "DEFAULTSTYLE", str); } else { SetEntrezAppParam ("PREFERENCES", "DEFAULTSTYLE", "0"); } CleanupEntrez (); ArrowCursor (); return 0; }
Int2 Main() { AsnIoPtr aip; BioseqPtr bsp; Pointer dataptr; Uint2 datatype; Boolean found; SPI_mRNAToHerdPtr h_head; SPI_mRNAToHerdPtr h_prev; SPI_mRNAToHerdPtr hptr; FILE *ifp; Boolean isGIlist; Char line[60]; Boolean lowercase; SeqLocPtr lcaseloc; FILE *ofp; FILE *ofp2; SeqAlignPtr sap; SeqAnnotPtr sanp; SeqEntryPtr sep; FILE *sfp; SeqIdPtr sip; SeqLocPtr slp; SPI_bsinfoPtr spig; SPI_bsinfoPtr spig_head; SPI_bsinfoPtr spig_prev; SPI_bsinfoPtr spim; SPI_bsinfoPtr spim_head; SPI_bsinfoPtr spim_prev; SPI_OptionsPtr spot; SPI_RegionInfoPtr srip = NULL; SPI_RegionInfoPtr srip_head; SPI_RegionInfoPtr srip_prev; CharPtr str; CharPtr txt; ID1BioseqFetchEnable("spidey", FALSE); LocalSeqFetchInit(FALSE); /* standard setup */ ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! FeatDefSetLoad ()) { Message (MSG_FATAL, "FeatDefSetLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } if (!GetArgs("SPIDEY", NUMARGS, myargs)) return 0; /* set the error message level high to suppress warnings from BLAST */ isGIlist = (Boolean)myargs[MYARGGILIST].intvalue; txt = myargs[MYARGGENFILE].strvalue; ifp = FileOpen(txt, "r"); spig_head = NULL; if (ifp == NULL) { bsp = SPI_GetBspFromGIOrAcc(txt); if (bsp == NULL) { ErrPostEx(SEV_ERROR, 0, 0, "Can't open genomic input file\n"); return -1; } else { spig_head = (SPI_bsinfoPtr)MemNew(sizeof(SPI_bsinfo)); spig_head->bsp = bsp; } } if (spig_head == NULL) { spig_prev = NULL; /* read in the genomic sequence(s) first and put them into bsinfo structures */ while ((dataptr = ReadAsnFastaOrFlatFile (ifp, &datatype, NULL, FALSE, FALSE, TRUE, FALSE)) != NULL) { if (datatype == OBJ_BIOSEQ) { spig = (SPI_bsinfoPtr)MemNew(sizeof(SPI_bsinfo)); spig->bsp = (BioseqPtr)dataptr; if (spig_head == NULL) spig_head = spig_prev = spig; else { spig_prev->next = spig; spig_prev = spig; } } else if (datatype == OBJ_SEQENTRY) { sep = (SeqEntryPtr)dataptr; SeqEntryExplore(sep, &spig_head, SPI_FindAllNuc); } } FileClose(ifp); } if (spig_head == NULL) { ErrPostEx(SEV_ERROR, 0, 0, "No valid bioseqs in genomic file\n"); return -1; } else if (ISA_aa(spig_head->bsp->mol)) { ErrPostEx(SEV_ERROR, 0, 0, "At least one of the genomic sequences appears to be a protein.\n"); return -1; } if (spig_head->next != NULL) { ErrPostEx(SEV_ERROR, 0, 0, "This version can only process one genomic sequence at a time. Only the first sequence in this file will be used.\n"); spig_head->next = NULL; } spim_head = spim_prev = NULL; txt = myargs[MYARGMRNAFILE].strvalue; ifp = FileOpen(txt, "r"); if (ifp == NULL) { bsp = SPI_GetBspFromGIOrAcc(txt); if (bsp == NULL) { ErrPostEx(SEV_ERROR, 0, 0, "Can't open mRNA input file\n"); return -1; } else { spim_head = (SPI_bsinfoPtr)MemNew(sizeof(SPI_bsinfo)); spim_head->bsp = bsp; } } if (spim_head == NULL) { lowercase = (Boolean)myargs[MYARGMASKED].intvalue; lcaseloc = NULL; /* if the mRNA has lowercase masking, read it in carefully to record the masking */ if (lowercase == TRUE) { while ((sep = FastaToSeqEntryForDb(ifp, TRUE, NULL, TRUE, NULL, NULL, &lcaseloc)) != NULL) { SeqEntryExplore(sep, &spim_head, SPI_FindAllNuc); if (lcaseloc != NULL) /* put masking info into the bsinfo structure */ { spim = spim_head; sip = SeqLocId(lcaseloc); found = FALSE; while (spim != NULL && !found) { if (SeqIdComp(sip, spim->bsp->id) == SIC_YES) { found = TRUE; spim->lcaseloc = lcaseloc; } spim = spim->next; } lcaseloc = NULL; } } } else if (isGIlist) /* mRNA file is a list of GIs, must fetch the bioseqs */ { str = ReadALine(line, sizeof(line), ifp); while (str != NULL) { bsp = SPI_GetBspFromGIOrAcc(str); if (bsp != NULL) { spim = (SPI_bsinfoPtr)MemNew(sizeof(SPI_bsinfo)); spim->bsp = bsp; if (spim_head == NULL) spim_head = spim_prev = spim; else { spim_prev->next = spim; spim_prev = spim; } } str = ReadALine(line, sizeof(line), ifp); } } else /* mRNAs are FASTA or ASN.1, read them all in */ { while ((dataptr = ReadAsnFastaOrFlatFile (ifp, &datatype, NULL, FALSE, FALSE, TRUE, FALSE)) != NULL) { if (datatype == OBJ_BIOSEQ) { spim = (SPI_bsinfoPtr)MemNew(sizeof(SPI_bsinfo)); spim->bsp = (BioseqPtr)dataptr; if (spim_head == NULL) spim_head = spim_prev = spim; else { spim_prev->next = spim; spim_prev = spim; } } else if (datatype == OBJ_SEQENTRY) { sep = (SeqEntryPtr)dataptr; SeqEntryExplore(sep, &spim_head, SPI_FindAllNuc); } } } FileClose(ifp); } if (spim_head == NULL) { ErrPostEx(SEV_ERROR, 0, 0, "No valid bioseqs in mRNA file\n"); return -1; } else if (ISA_aa(spim_head->bsp->mol)) { ErrPostEx(SEV_ERROR, 0, 0, "At least one of the mRNA sequences appears to be a protein\n"); return -1; } txt = myargs[MYARGTABLE].strvalue; if (txt != NULL) { ifp = FileOpen(txt, "r"); if (ifp == NULL) { ErrPostEx(SEV_ERROR, 0, 0, "Unable to open table file\n"); return -1; } SPI_ReadFeatureTable(ifp, spim_head); spim = spim_head; while (spim != NULL) { if (spim->lcaseloc != NULL) { slp = (SeqLocPtr)ValNodeNew(NULL); slp->choice = SEQLOC_MIX; slp->data.ptrvalue = (Pointer)spim->lcaseloc; spim->lcaseloc = slp; } spim = spim->next; } } spim = spim_head; spot = (SPI_OptionsPtr)MemNew(sizeof(SPI_Options)); spot->printaln = myargs[MYARGPRALIGN].intvalue; txt = myargs[MYARGOUTFILE].strvalue; ofp = FileOpen(txt, "w"); if (ofp == NULL && spot->printaln != 3) { ErrPostEx(SEV_ERROR, 0, 0, "Unable to open output file\n"); return -1; } if (spot->printaln >= 2) { txt = myargs[MYARGALNFILE].strvalue; ofp2 = FileOpen(txt, "a"); if (ofp2 == NULL) { ErrPostEx(SEV_ERROR, 0, 0, "Unable to open output file 2\n"); return -1; } } else ofp2 = NULL; /** ErrSetMessageLevel(SEV_MAX); **/ spot->firstpasseval = myargs[MYARG1STEVAL].floatvalue; spot->secpasseval = myargs[MYARG2NDEVAL].floatvalue; spot->thirdpasseval = myargs[MYARG3RDEVAL].floatvalue; spot->numreturns = myargs[MYARGNUMMOD].intvalue; spot->idcutoff = myargs[MYARGIDCUT].intvalue; spot->lencutoff = myargs[MYARGLENCUT].intvalue; spot->interspecies = (Boolean)myargs[MYARGSPEC].intvalue; spot->printasn = (Boolean)myargs[MYARGASN].intvalue; spot->fetchcds = (Boolean)myargs[MYARGGETCDS].intvalue; /*spot->ace = (Boolean)myargs[MYARGACEDB].intvalue;*/ spot->from = myargs[MYARGFROM].intvalue; spot->to = myargs[MYARGTO].intvalue; spot->makemult = (Boolean)myargs[MYARGMULT].intvalue; /*KSK*/ spot->bigintron = (Boolean)myargs[MYARGXL].intvalue; spot->bigintron_size = myargs[MYARGXL_SIZE].intvalue; spot->repeat_db_file = myargs[MYARGREPDB].strvalue; txt = myargs[MYARGORG].strvalue; if (!StringICmp(txt, "d") || !StringICmp(txt, "D")){ spot->organism = SPI_FLY; } else if (!StringICmp(txt, "p") || !StringICmp(txt, "P")){ spot->organism = SPI_PLANT; } else if (!StringICmp(txt, "c") || !StringICmp(txt, "C")){ spot->organism = SPI_CELEGANS; } else if (!StringICmp(txt, "m") || !StringICmp(txt, "M")){ spot->organism = SPI_DICTY; } else { spot->organism = SPI_VERTEBRATE; } sap = NULL; if (spot->printasn) spot->sap_head = &sap; txt = myargs[MYARGSTRAND].strvalue; if (txt != NULL) { if (StrChr(txt, 'p') || StrChr(txt, 'P')) spot->strand = Seq_strand_plus; else spot->strand = Seq_strand_minus; } else spot->strand = Seq_strand_both; /*txt = myargs[MYARGDRAFTFILE].strvalue; if (txt != NULL) spot->draftfile = StringSave(txt);*/ txt = myargs[MYARGDSPLICE].strvalue; if (txt != NULL) { sfp = FileOpen(txt, "r"); SPI_GetSpliceInfo(spot, sfp, TRUE); FileClose(sfp); } txt = myargs[MYARGASPLICE].strvalue; if (txt != NULL) { sfp = FileOpen(txt, "r"); SPI_GetSpliceInfo(spot, sfp, FALSE); FileClose(sfp); } h_head = h_prev = NULL; srip_head = srip_prev = NULL; while (spim != NULL) { spot->lcaseloc = spim->lcaseloc; if (spot->draftfile == NULL) srip = SPI_AlnSinglemRNAToGen(spig_head, spim, ofp, ofp2, spot); else { hptr = SPI_AlnSinglemRNAToPieces(spig_head, spim, ofp, ofp2, spot); if (h_head != NULL) { h_prev->next = hptr; h_prev = hptr; } else h_head = h_prev = hptr; } if (srip != NULL) { if (srip_head != NULL) { srip_prev->next = srip; srip_prev = srip; } else srip_head = srip_prev = srip; } spim = spim->next; } if (spot->makemult) { SPI_MakeMultipleAlignment(srip_head); SPI_PrintMultipleAlignment(srip_head, FALSE, spig_head->bsp, ofp); SPI_RegionListFree(srip_head); } else SPI_RegionListFree(srip_head); /* create the ASN.1 output, if requested; need to use the continuous alignment */ /* that was generated */ if (spot->printasn && *(spot->sap_head) != NULL && spot->draftfile == NULL) { sanp = SeqAnnotForSeqAlign(*(spot->sap_head)); txt = myargs[MYARGASNFILE].strvalue; aip = AsnIoOpen(txt, "w"); SeqAnnotAsnWrite(sanp, aip, NULL); AsnIoClose(aip); SeqAlignSetFree(*(spot->sap_head)); } FileClose(ofp); FileClose(ofp2); SPI_OptionsFree(spot); SPI_bsinfoFreeList(spim_head); SPI_bsinfoFreeList(spig_head); LocalSeqFetchDisable(); ID1BioseqFetchDisable(); return 0; }
Int2 Main(void) { UDVLogoDataPtr ldp; Boolean UseNetwork; WindoW w; DdvMainWinPtr mWin_d;/*main window data*/ ObjMgrPtr omp = NULL; Boolean NoGaps; if ( !Nlm_GetArgsSilent("DDV 1.0", NUMARGS, DDV_myargs) ) return 1; ErrSetMessageLevel(SEV_WARNING); ErrSetOptFlags(EO_SHOW_CODES); ErrSetOptFlags(EO_XLATE_CODES); /*init some important stuffs*/ UseLocalAsnloadDataAndErrMsg(); if (! AllObjLoad()){ Message (MSG_ERROR, "AsnObjLoad() failed."); return(1); } if (! SubmitAsnLoad()){ Message (MSG_ERROR, "SeqSubmitLoad() failed."); return(1); } if (!SeqCodeSetLoad ()){ Message (MSG_ERROR, "SeqCodeSetLoad () failed."); return(1); } if (!GeneticCodeTableLoad()){ Message (MSG_ERROR, "GeneticCodeTableLoad() failed."); return(1); } if (!FeatDefSetLoad()){ Message (MSG_ERROR, "FeatDefSeqLoad() failed."); return(1); } /*init data blocks*/ mWin_d=(DdvMainWinPtr)MemNew(sizeof(DdvMainWin)); if (!mWin_d){ Message (MSG_ERROR, "Viewer creation failed."); return(1); } /* look for "nogaps" runtime parameter */ NoGaps = (Boolean)DDV_myargs[0].intvalue; SetAppProperty("dde_nogaps",(void*)&NoGaps); mWin_d->EditAllowed = (Boolean)DDV_myargs[1].intvalue; /*init data blocks*/ ldp=(UDVLogoDataPtr)MemNew(sizeof(UDVLogoData)); if (ldp){ MemSet(ldp,0,sizeof(UDVLogoData)); } else{ Message (MSG_ERROR, "Viewer creation failed."); return(1); } /*OBjMgr Callback Function declaration*/ /* REG_DDV_AUTO_EDIT; */ REG_DDV_AUTO_VIEW; REGISTER_UDV_AUTONOMOUS; REG_DDV_SLA_EDIT; /* increment maximum # of objects held in memory */ omp = ObjMgrWriteLock(); if(omp != NULL ) omp->maxtemp = DDV_MAXTEMP; ObjMgrUnlock(); w=DDV_StartMainWin_Master(mWin_d,ldp); if (w==NULL) goto fin; ProcessUpdatesFirst(FALSE); UseNetwork=mWin_d->UseNetwork; /*display main window*/ RealizeWindow(w); Show(w); /*enter loop events*/ ProcessEvents(); fin: /*close network connection, if needed*/ if (UseNetwork && EntrezIsInited()) EntrezBioseqFetchDisable(); /*clean up*/ if (ldp) MemFree(ldp); RemoveAppProperty("UDVLogoData"); return(0); }
Int2 Main(void) { Char app [64]; CharPtr directory; CharPtr ptr; Char sfx [32]; OutputStreamData osd; InputStreamData isd; AsnStreamData asd; Int4 gap_sizes[2]; Int4 rval = 0; Int4 u_eq = 0, u_gteq = -1, k_eq = 0, k_gteq = -1; /* standard setup */ ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); /* finish resolving internal connections in ASN.1 parse tables */ if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! FeatDefSetLoad ()) { Message (MSG_FATAL, "FeatDefSetLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } SetUpAsnStreamData (&asd); /* initialize OuputStreamData */ MemSet (&osd, 0, sizeof (osd)); /* initialize InputStreamData */ MemSet (&isd, 0, sizeof (isd)); /* initialize gap_sizes */ gap_sizes[0] = 0; gap_sizes[1] = 0; /* process command line arguments */ sprintf (app, "raw2delt %s", RAW2DELT_APPLICATION); if (! GetArgs (app, sizeof (myargs) / sizeof (Args), myargs)) { return 0; } u_eq = (Int4) myargs [u_argEqUnknownGap].intvalue; u_gteq = (Int4) myargs [U_argGTEqUnknownGap].intvalue; k_eq = (Int4) myargs [k_argEqUnknownGap].intvalue; k_gteq = (Int4) myargs [K_argGtEqUnknownGap].intvalue; if (u_eq < 1 && u_gteq < 1 && k_eq < 1 && k_gteq < 1) { Message (MSG_FATAL, "Must specify values for at least one of -u, -U, -k, -K"); return 1; } else if (u_eq > -1 && u_gteq > -1) { Message (MSG_FATAL, "May only specify value for -u or -U, not both"); return 1; } else if (k_eq > -1 && k_gteq > -1) { Message (MSG_FATAL, "May only specify value for -k or -K, not both"); return 1; } if (u_eq > 0) { gap_sizes[0] = u_eq; } else if (u_gteq > 0) { gap_sizes[0] = 0 - u_gteq; } if (k_eq > 0) { gap_sizes[1] = k_eq; } else if (k_gteq > 0) { gap_sizes[1] = 0 - k_gteq; } if (gap_sizes[0] == gap_sizes[1]) { Message (MSG_FATAL, "Cannot specify the same size for known and unknown length gaps"); return 1; } directory = (CharPtr) myargs [p_argInputPath].strvalue; osd.results_dir = (CharPtr) myargs [r_argOutputPath].strvalue; if (StringHasNoText (osd.results_dir)) { osd.results_dir = NULL; } osd.suffix = (CharPtr) myargs [x_argSuffix].strvalue; osd.outsuffix = (CharPtr) myargs [s_argOutSuffix].strvalue; osd.base = (CharPtr) myargs [i_argInputFile].strvalue; osd.outfile = (CharPtr) myargs [o_argOutputFile].strvalue; if (StringHasNoText (osd.outfile)) { osd.outfile = NULL; } osd.is_binary = (Boolean) myargs [d_argOutputBinary].intvalue; if (osd.base == "stdin") { osd.base = NULL; } /* if we don't have an output directory or an output file, and the user hasn't provided an * output suffix, add a default. */ if (osd.results_dir == NULL && osd.outfile == NULL && StringHasNoText (osd.outsuffix)) { osd.outsuffix = ".delta"; } isd.is_binary = (Boolean) myargs [b_argInputBinary].intvalue; isd.is_seqentry = (Boolean) myargs [e_argInputSeqEntry].intvalue; isd.directory = directory; isd.base = osd.base; isd.suffix = osd.suffix; if (StringDoesHaveText (osd.outfile)) { osd.aip = AsnIoOpen (osd.outfile, "w"); if (osd.aip == NULL) { Message (MSG_FATAL, "Unable to open output file"); return 1; } } else { if (StringHasNoText (osd.results_dir)) { osd.results_dir = directory; } /* if we're putting the results in a separate directory, strip the directory name from the output base */ if (!StringHasNoText (osd.results_dir) && !StringHasNoText (osd.base)) { #ifdef OS_MSWIN ptr = StringRChr (osd.base, '\\'); #else ptr = StringRChr (osd.base, '/'); #endif; if (ptr != NULL) { osd.base = ptr + 1; } } } if (StringHasNoText(directory) && StringHasNoText(osd.base)) { rval = ProcessStream (&isd, &osd, &asd, gap_sizes); } else if (StringDoesHaveText (osd.base)) { ptr = StringRChr (osd.base, '.'); sfx[0] = '\0'; if (ptr != NULL) { StringNCpy_0 (sfx, ptr, sizeof (sfx)); *ptr = '\0'; } osd.suffix = sfx; isd.suffix = sfx; if (isd.is_binary) { rval = ProcessStream (&isd, &osd, &asd, gap_sizes); } else { rval = ProcessOneRecord (directory, &osd, gap_sizes); } } else { rval = FileRecurse (directory, &isd, &osd, &asd, gap_sizes); } if (osd.aip != NULL) { AsnIoFlush (osd.aip); AsnIoClose (osd.aip); } return rval; }
Int2 Main (void) { CharPtr base, directory, outfile, suffix, ptr; BioseqSetPtr bssp; ValNodePtr head, vnp; SeqEntryPtr sep; SeqSubmitPtr ssp; /* standard setup */ ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); /* finish resolving internal connections in ASN.1 parse tables */ if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! FeatDefSetLoad ()) { Message (MSG_FATAL, "FeatDefSetLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } /* process command line arguments */ if (! GetArgs ("subfuse", sizeof (myargs) / sizeof (Args), myargs)) { return 0; } directory = (CharPtr) myargs [p_argInputPath].strvalue; outfile = (CharPtr) myargs [o_argOutputFile].strvalue; suffix = (CharPtr) myargs [x_argSuffix].strvalue; bssp = BioseqSetNew (); if (bssp == NULL) return 0; bssp->_class = BioseqseqSet_class_genbank; sep = SeqEntryNew (); if (sep == NULL) return 0; sep->choice = 2; sep->data.ptrvalue = (Pointer) bssp; ssp = SeqSubmitNew (); if (ssp == NULL) return 0; ssp->datatype = 1; ssp->data = (Pointer) sep; /* get list of all files in source directory */ head = DirCatalog (directory); for (vnp = head; vnp != NULL; vnp = vnp->next) { if (vnp->choice == 0) { base = (CharPtr) vnp->data.ptrvalue; if (! StringHasNoText (base)) { ptr = StringStr (base, suffix); if (ptr != NULL) { *ptr = '\0'; Message (MSG_POST, "Processing %s\n", base); ProcessOneRecord (ssp, bssp, directory, base, suffix); } } } } /* clean up file list */ ValNodeFreeData (head); /* write output file */ WriteOneSubmission (outfile, ssp); return 0; }
Int2 Main (void) { Int2 db = -1; Int2 i; Boolean makeCDS; Char path [PATH_MAX]; CharPtr progname; FILE *fp; Int2 rsult; ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } ProgramPath (path, sizeof (path)); progname = StringRChr (path, DIRDELIMCHR); if (progname != NULL) { progname++; } else { progname = "fetchent"; } /* GetArgs is a portable way of obtaining arguments */ if (! GetArgs (progname, NUMARG, myargs)) { Message (MSG_FATAL, "GetArgs failed"); return 1; } /* Map database argument to TYP_XX value */ for (i = 0; databases [i] != NULL; i++) { if (StringICmp (myargs [0].strvalue, databases [i]) == 0) { db = i; } } /* Convert M, P, or N alternative database symbols to proper code */ if (db >= 3 && db <= 5) { db -= 3; } if (db < 0 || db > 2) { Message (MSG_FATAL, "Database must be ML, AA, or NT"); return 1; } if (! EntrezInit (progname, FALSE, NULL)) { Message (MSG_FATAL, "EntrezInit failed"); return 1; } fp = FileOpen (myargs [2].strvalue, "w"); if (fp == NULL) { Message (MSG_FATAL, "FileOpen failed"); return 1; } makeCDS = (Boolean) myargs [3].intvalue; if (makeCDS && db != TYP_NT) { Message (MSG_ERROR, "Coding region extraction inappropriate"); makeCDS = FALSE; } rsult = ProcessQuery (db, myargs [1].strvalue, makeCDS, fp); FileClose (fp); EntrezFini (); return rsult; }
Int2 Main (void) { Char app [64], type; CSpeedFlagData cfd; CharPtr directory, filter, infile, logfile, outfile, str, suffix; Boolean remote; time_t runtime, starttime, stoptime; /* standard setup */ ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); /* finish resolving internal connections in ASN.1 parse tables */ if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! FeatDefSetLoad ()) { Message (MSG_FATAL, "FeatDefSetLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } /* process command line arguments */ sprintf (app, "cspeedtest %s", CSPEEDTEST_APPLICATION); if (! GetArgs (app, sizeof (myargs) / sizeof (Args), myargs)) { return 0; } MemSet ((Pointer) &cfd, 0, sizeof (CSpeedFlagData)); directory = (CharPtr) myargs [p_argInputPath].strvalue; infile = (CharPtr) myargs [i_argInputFile].strvalue; outfile = (CharPtr) myargs [o_argOutputFile].strvalue; filter = (CharPtr) myargs [f_argFilter].strvalue; suffix = (CharPtr) myargs [x_argSuffix].strvalue; cfd.batch = FALSE; cfd.binary = (Boolean) myargs [b_argBinary].intvalue; cfd.compressed = (Boolean) myargs [c_argCompressed].intvalue; cfd.lock = (Boolean) myargs [l_argLockFar].intvalue; cfd.type = 1; str = myargs [a_argType].strvalue; TrimSpacesAroundString (str); if (StringDoesHaveText (str)) { type = str [0]; } else { type = 'a'; } type = TO_LOWER (type); switch (type) { case 'a' : cfd.type = 1; break; case 'e' : cfd.type = 2; break; case 'b' : cfd.type = 3; break; case 's' : cfd.type = 4; break; case 'm' : cfd.type = 5; break; case 't' : cfd.type = 1; cfd.batch = TRUE; break; case 'f' : cfd.type = 6; break; case 'l' : cfd.type = 7; break; default : cfd.type = 1; break; } remote = (Boolean) myargs [R_argRemote].intvalue; cfd.maxcount = myargs [X_argMaxCount].intvalue; if (cfd.maxcount < 1) { cfd.maxcount = 1; } cfd.io = myargs [O_argInOut].strvalue; cfd.clean = myargs [K_argClean].strvalue; cfd.skip = myargs [P_argSkip].strvalue; cfd.index = myargs [I_argIndex].strvalue; cfd.seq = myargs [S_argSeq].strvalue; cfd.feat = myargs [F_argFeat].strvalue; cfd.desc = myargs [D_argDesc].strvalue; cfd.verify = myargs [V_argVerify].strvalue; cfd.amp = AsnAllModPtr (); cfd.atp_bss = AsnFind ("Bioseq-set"); cfd.atp_bsss = AsnFind ("Bioseq-set.seq-set"); cfd.atp_se = AsnFind ("Bioseq-set.seq-set.E"); cfd.atp_bsc = AsnFind ("Bioseq-set.class"); cfd.bssp_atp = AsnLinkType (NULL, cfd.atp_bss); logfile = (CharPtr) myargs [L_argLogFile].strvalue; if (StringDoesHaveText (logfile)) { cfd.logfp = FileOpen (logfile, "w"); } if (remote) { PubSeqFetchEnable (); } if (StringDoesHaveText (outfile)) { cfd.ofp = FileOpen (outfile, "w"); } starttime = GetSecs (); if (StringDoesHaveText (directory)) { DirExplore (directory, NULL, suffix, FALSE, ProcessOneRecord, (Pointer) &cfd); } else if (StringDoesHaveText (infile)) { ProcessOneRecord (infile, (Pointer) &cfd); } if (cfd.ofp != NULL) { FileClose (cfd.ofp); } stoptime = GetSecs (); runtime = stoptime - starttime; if (cfd.logfp != NULL) { fprintf (cfd.logfp, "Finished in %ld seconds\n", (long) runtime); FileClose (cfd.logfp); } printf ("Finished in %ld seconds\n", (long) runtime); if (remote) { PubSeqFetchDisable (); } return 0; }
Int2 Main (void) { AsnIoPtr aip; AsnTypePtr atp; FILE *dfp = NULL; Boolean do_nuc = FALSE; Boolean do_prot = FALSE; XtraPtr extra; FILE *fp; GBSeq gbsq; GBSet gbst; Boolean get_var; Char line [256]; Boolean only_new; CharPtr str; Char xmlbuf [128]; XtraBlock xtra; ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } if (! objgbseqAsnLoad ()) { Message (MSG_POSTERR, "objgbseqAsnLoad failed"); return 1; } if (! GetArgs ("gbseqget", sizeof (myargs) / sizeof (Args), myargs)) { return 0; } fp = FileOpen (myargs [i_argInputFile].strvalue, "r"); if (fp == NULL) { return 1; } if (! StringHasNoText (myargs [d_argDateFile].strvalue)) { dfp = FileOpen (myargs [d_argDateFile].strvalue, "r"); if (dfp == NULL) { return 1; } } if (GetAppParam ("NCBI", "SETTINGS", "XMLPREFIX", NULL, xmlbuf, sizeof (xmlbuf))) { AsnSetXMLmodulePrefix (StringSave (xmlbuf)); } MemSet ((Pointer) &xtra, 0, sizeof (XtraBlock)); MemSet ((Pointer) &gbsq, 0, sizeof (GBSeq)); xtra.gbseq = &gbsq; aip = AsnIoOpen (myargs [o_argOutputFile].strvalue, "wx"); if (aip == NULL) { Message (MSG_POSTERR, "AsnIoOpen failed"); FileClose (fp); return 1; } only_new = (Boolean) myargs [n_argNewRecords].intvalue; get_var = (Boolean) myargs [v_argVariations].intvalue; str = myargs [m_argMolecule].strvalue; if (StringICmp (str, "n") == 0) { do_nuc = TRUE; } else if (StringICmp (str, "p") == 0) { do_prot = TRUE; } else if (StringICmp (str, "b") == 0) { do_nuc = TRUE; do_prot = TRUE; } else { do_nuc = TRUE; } PubSeqFetchEnable (); xtra.aip = aip; atp = AsnLinkType (NULL, AsnFind ("GBSet")); xtra.atp = AsnLinkType (NULL, AsnFind ("GBSet.E")); if (atp == NULL || xtra.atp == NULL) { Message (MSG_POSTERR, "AsnLinkType or AsnFind failed"); return 1; } extra = &xtra; MemSet ((Pointer) &gbst, 0, sizeof (GBSet)); AsnOpenStruct (aip, atp, (Pointer) &gbst); if (dfp != NULL) { DoQuery (fp, dfp, extra, get_var, do_nuc, do_prot); } else { str = ReadALine (line, sizeof (line), fp); while (str != NULL) { if (! StringHasNoText (str)) { ProcessAccession (str, extra, only_new, get_var, do_nuc, do_prot); } str = ReadALine (line, sizeof (line), fp); } } AsnCloseStruct (aip, atp, NULL); AsnPrintNewLine (aip); AsnIoClose (aip); FileClose (dfp); FileClose (fp); PubSeqFetchDisable (); return 0; }