static BioseqPtr DOT_GetBspFromGIOrAcc(CharPtr str) { BioseqPtr bsp; Int4 gi; Char ptr; SeqIdPtr sip; ValNode vn; LinkSetPtr lsp; Int4 uid; str = TrimSpacesAroundString(str); ptr = *str; if (IS_ALPHA(ptr)) /* accession */ { sip = SeqIdFromAccessionDotVersion(str); bsp = BioseqLockById(sip); } else /* it's a GI */ { gi = atoi(str); vn.choice = SEQID_GI; vn.data.intvalue = gi; vn.next = NULL; bsp = BioseqLockById(&vn); } return bsp; }
static BioseqPtr FetchOnlyBioseqFromID (CharPtr str) { BioseqPtr bsp = NULL; Uint2 entityID; SeqEntryPtr sep; SeqIdPtr sip = NULL; Int4 uid; time_t t1, t2; t1 = time (NULL); uid = 0; TrimSpacesAroundString (str); if (IsAllDigits (str)) { if (PvtStrToLong (str, &uid)) { sip = ValNodeNew(NULL); sip->choice = SEQID_GI; sip->data.intvalue = uid; } else { uid = 0; } } else { sip = SeqIdFromAccessionDotVersion (str); uid = AccessionToGi (str); } sep = NULL; if (uid > 0) { sep = PubSeqSynchronousQuery (uid, 3, 0); /* retcode was 0 */ if (sep != NULL) { bsp = BioseqFindInSeqEntry (sip, sep); entityID = ObjMgrGetEntityIDForChoice (sep); } } sip = SeqIdFree (sip); if (debug_mode) { t2 = time (NULL); if (t2 - t1 > 1) { printf ("Time to download %s from ID:%d\n", str, (int) (t2 - t1)); } } return bsp; }
static void AddSpecMember ( ButtoN b ) { Char buf [128]; DollarAmountPtr dap; Int2 days = 0; MiscRatePtr mrp; SscSpecPtr ssp; SscTablesPtr stp; Int2 which; ssp = (SscSpecPtr) GetObjectExtra (b); if (ssp == NULL) return; stp = ssp->tables; if (stp == NULL) return; mrp = stp->miscrate_table; if (mrp == NULL) return; GetTitle (ssp->name, buf, sizeof (buf)); if (StringHasNoText (buf)) return; TrimSpacesAroundString (buf); if (! NormalizeAuthorCaps (buf)) return; which = GetValue (ssp->whichspec); if (which < 1) return; switch (which) { case 1 : days = mrp->special_memb_days; if (days < 0) { days = 0; } if (AddToTempMemberList (stp, buf, days)) { AddToContactList (stp->new_contacts, buf, VISITING_MEMBER); if (GetStatus (ssp->visitfee)) { dap = mrp->visiting_fee; if (dap != NULL) { AddFeeItem (stp->fees, buf, 0, NULL, dap->dollars, dap->cents, VISITING_MEMB_FEE, NULL, NULL); } } } break; case 2 : days = mrp->special_memb_days; if (days < 0) { days = 0; } if (AddToTempMemberList (stp, buf, days)) { AddToContactList (stp->new_contacts, buf, AFFIL_MEMBER); if (GetStatus (ssp->affilfee)) { dap = mrp->affiliated_fee; if (dap != NULL) { AddFeeItem (stp->fees, buf, 0, NULL, dap->dollars, dap->cents, AFFIL_MEMB_FEE, NULL, NULL); } } } break; case 3 : if (AddToFullMemberList (stp, buf, ssp->jobs)) { AddToContactList (stp->new_contacts, buf, TRANSIENT_MEMBER); if (GetStatus (ssp->transfee)) { dap = &(ssp->proratedtrans); if (dap != NULL) { AddFeeItem (stp->fees, buf, 0, NULL, dap->dollars, dap->cents, TRANS_MEMB_FEE, NULL, NULL); } } if (GetStatus (ssp->transssa)) { dap = &(ssp->proratedssa); if (dap != NULL) { AddFeeItem (stp->fees, buf, 0, NULL, dap->dollars, dap->cents, SSA_DUES_FEE, NULL, NULL); } } } break; default : break; } SafeHide (ssp->namegroup); SafeHide (ssp->controls [ssp->currPage]); SafeSetValue (ssp->whichspec, 0); ssp->currPage = 0; SetTitle (ssp->name, ""); SetStatus (ssp->visitfee, TRUE); SetStatus (ssp->affilfee, TRUE); SetStatus (ssp->transfee, TRUE); SetStatus (ssp->transssa, TRUE); SetClubJobs (ssp->jobs, FALSE, FALSE, FALSE, FALSE); Disable (b); Update (); }
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; }