/*---------------- replace original seq_id by local_id --------------*/ void AssignLocaIdToBiostruc(SeqIdPtr sip, Char *PDBName, Char Chain,BiostrucPtr bsp) { BiostrucDescrPtr pbsdrThis = NULL; MoleculeGraphPtr pmgThis = NULL; BiomolDescrPtr pbmdrThis = NULL; Char ThisPDBName[Local_max], *ThisChain; StringCpy(ThisPDBName, PDBNAME_DEFAULT); pbsdrThis = ValNodeFindNext(bsp->descr, NULL, BiostrucDescr_name); if(pbsdrThis) StringNCpy(ThisPDBName, pbsdrThis ->data.ptrvalue, 4); /*if(StringCmp(PDBName, ThisPDBName) != 0) { printf("Something is wrong!\n"); return; } */ pmgThis = bsp->chemical_graph->molecule_graphs; while(pmgThis) { /* loop over molecule_graphs to match chain */ pbmdrThis = ValNodeFindNext(pmgThis->descr, NULL, BiomolDescr_name); if(pbmdrThis){ ThisChain = StringSave((CharPtr)pbmdrThis->data.ptrvalue); } else ThisChain = StringSave(STRING_UNK_MOL); if(Chain == *ThisChain) { pmgThis->seq_id = sip; return; } pmgThis = pmgThis->next; } }
static ValNodePtr CollectBioseqLineValues (BioseqPtr bsp, ValNodePtr field_list, Boolean want_gi) { SeqDescrPtr sdp; SeqMgrDescContext dcontext; Char id_txt[255], id_txt2[255]; SeqIdPtr sip, sip_gi = NULL, sip_gb = NULL; ValNodePtr line_list = NULL, line_values; if (bsp == NULL) { return NULL; } for (sip = bsp->id; sip != NULL; sip = sip->next) { if (sip->choice == SEQID_GENBANK || (sip->choice == SEQID_EMBL && sip_gb == NULL) || (sip->choice == SEQID_SWISSPROT && sip_gb == NULL) || (sip->choice == SEQID_DDBJ && sip_gb == NULL) || (sip->choice == SEQID_PIR && sip_gb == NULL)) { sip_gb = sip; } else if (sip->choice == SEQID_GI) { sip_gi = sip; } } if (sip_gb == NULL && sip_gi == NULL) { SeqIdWrite (SeqIdFindBest (bsp->id, SEQID_GENBANK), id_txt, PRINTID_REPORT, sizeof (id_txt) - 1); id_txt2[0] = 0; } else { if (sip_gb == NULL) { id_txt[0] = 0; } else { SeqIdWrite (sip_gb, id_txt, PRINTID_REPORT, sizeof (id_txt) - 1); } if (sip_gi == NULL) { id_txt2[0] = 0; } else { SeqIdWrite (sip_gi, id_txt2, PRINTID_REPORT, sizeof (id_txt2) - 1); } } for (sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext); sdp != NULL; sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_source, &dcontext)) { line_values = NULL; ValNodeAddPointer (&line_values, 0, StringSave (id_txt)); if (want_gi) { ValNodeAddPointer (&line_values, 0, StringSave (id_txt2)); } ValNodeLink (&line_values, CollectBioSourceValues (sdp->data.ptrvalue, field_list)); ValNodeAddPointer (&line_list, 0, line_values); } return line_list; }
PDNMG CpyPDNMGList(PDNMG pdnmg, PMMD pmmdNew) { PDNMG pdnmgNew = NULL, pdnmgNewHead = NULL, pdnmgLast = NULL; PMGD pmgdNew = NULL, pmgdParent = NULL; while(pdnmg) { pmgdParent = (PMGD)(pdnmg->data.ptrvalue); pdnmgNew = DValNodeNew(NULL); pdnmgNew->choice = pdnmg->choice; pmgdNew = NewMGD(); pmgdNew->pfbParent = (PFB)pmmdNew; pmgdNew->bWhat = pmgdParent->bWhat; pmgdNew->bNCBISecStru = pmgdParent->bNCBISecStru; pmgdNew->bPDBSecStru = pmgdParent->bPDBSecStru; pmgdNew->pdnmgLink = pdnmgNew; pmgdNew->iDomain = pmgdParent->iDomain; if(pmgdParent->pcGraphName) { pmgdNew->pcGraphName = StringSave(pmgdParent->pcGraphName); } if(pmgdParent->pcGraphNum) { pmgdNew->pcGraphNum = StringSave(pmgdParent->pcGraphNum); } pmgdNew->iIDict = pmgdParent->iIDict; if(pmgdParent->pcIUPAC) { pmgdNew->pcIUPAC = StringSave(pmgdParent->pcIUPAC); } pmgdNew->pcNCBISS = pmgdParent->pcNCBISS; pmgdNew->pcPDBSS = pmgdParent->pcPDBSS; if(pmgdParent->pcPDBComment) { pmgdNew->pcPDBComment = StringSave(pmgdParent->pcPDBComment); } pmgdNew->iAtomCount = pmgdParent->iAtomCount; pmgdNew->iBondCount = pmgdParent->iBondCount; pmgdNew->pvnmaAHead = CpyPVNMAList(pmgdParent->pvnmaAHead, pmgdNew); pdnmgNew->data.ptrvalue = (VoidPtr)pmgdNew; if(pdnmgNewHead == NULL) { pdnmgNewHead = pdnmgNew; pdnmgLast = pdnmgNew; } else { pdnmgLast->next = pdnmgNew; pdnmgNew->last = pdnmgLast; pdnmgLast = pdnmgNew; } pdnmg = pdnmg->next; } return pdnmgNewHead; }
/* Pops top StringStack item from StringStack */ CharPtr SLRI_SSPop(SLRI_SStackPtr ssp) { CharPtr string = NULL; SLRI_SStackItemPtr ssipNewTop = NULL; if (ssp == NULL) { ErrPostEx(SEV_ERROR, 0, 0, "SLRI_SSPop: stack pointer is NULL"); return(NULL); } if (SLRI_SSIsEmpty(ssp)) { ErrPostEx(SEV_ERROR, 0, 0, "SLRI_SSPop: stack is empty"); return(NULL); } ssipNewTop = ssp->top->prev; string = StringSave(ssp->top->string); ssp->top = MemFree(ssp->top); ssp->top = ssipNewTop; ssp->totalStackSize -= StringLen(string); ssp->totalNumItems--; /* If last item on stack, set bottom pointer to top */ if (ssp->top == NULL) { ssp->bottom = ssp->top; } return(string); }
static void FindBlastNR (SeqAnnotPtr sap, Pointer userdata) { AnnotDescrPtr adp; ObjectIdPtr oip; UserFieldPtr ufp; UserObjectPtr uop; if (sap == NULL || sap->type != 2) return; for (adp = sap->desc; adp != NULL; adp = adp->next) { if (adp->choice != Annot_descr_user) continue; for (uop = adp->data.ptrvalue; uop != NULL; uop = uop->next) { oip = uop->type; if (oip == NULL) continue; if (StringCmp (oip->str, "Blast Type") != 0) continue; ufp = uop->data; if (ufp == NULL) continue; oip = ufp->label; if (oip == NULL) continue; if (StringCmp (oip->str, "BLASTN - nr") != 0) continue; ProcessBlastNR (sap); oip->str = MemFree (oip->str); oip->str = StringSave ("BLASTN - nr minus mrna"); } } }
BiostrucFeaturePtr CpyPBSF(BiostrucFeaturePtr pbsfParent, Int4 newMolNum, Int4 lastFeatId, ResidueIntervalPntrPtr pri) { BiostrucFeaturePtr pbsfNew; ResidueIntervalPntrPtr priNew; ValNodePtr vnp, vnp2, vnp3; pbsfNew = BiostrucFeatureNew(); pbsfNew->id = lastFeatId + 1; pbsfNew->name = StringSave(pbsfParent->name); pbsfNew->type = pbsfParent->type; priNew = ResidueIntervalPntrNew(); priNew->molecule_id = newMolNum; priNew->from = pri->from; priNew->to = pri->to; vnp3=ValNodeNew(NULL); vnp3->choice=ResiduePntrs_interval; vnp3->data.ptrvalue=(VoidPtr)priNew; vnp2=ValNodeNew(NULL); vnp2->choice=ChemGraphPntrs_residues; vnp2->data.ptrvalue=(VoidPtr)vnp3; vnp=ValNodeNew(NULL); vnp->choice=Location_location_subgraph; vnp->data.ptrvalue=(VoidPtr)vnp2; pbsfNew->Location_location=vnp; return pbsfNew; }
NLM_EXTERN void NI_SetAddress(const Char *address) { NIOptions *nio = s_GetNIOptions(0,0); if ( nio->address ) MemFree(nio->address); nio->address = StringSave(address); }
static NI_DispatcherPtr s_GenericInit (CharPtr configFile, CharPtr configSection, Boolean showMonitor, CharPtr lastDispatcher, Int2 lastDispLen) { NI_DispatcherPtr disp = (NI_DispatcherPtr)MemNew(sizeof(NI_Dispatcher)); disp->interface = eNII_Debug; if ( lastDispatcher ) StringNCpy_0(lastDispatcher, "Debug NCBI Network Client", lastDispLen); disp->motd = StringSave("Makes a direct connection to the specified server"); disp->adminInfo = StringSave("Denis V. Vakatov " "([email protected])"); disp->referenceCount = 1; return disp; }
static SeqAnnotPtr MakeMrnaSeqAnnot (void) { AnnotDescrPtr adp; SeqAnnotPtr annot; ObjectIdPtr oip; UserFieldPtr ufp; UserObjectPtr uop; annot = SeqAnnotNew (); annot->type = 2; adp = ValNodeNew (NULL); adp->choice = Annot_descr_user; uop = UserObjectNew (); adp->data.ptrvalue = uop; oip = ObjectIdNew (); oip->str = StringSave ("Blast Type"); ufp = UserFieldNew (); uop->type = oip; uop->data = ufp; oip = ObjectIdNew (); oip->str = StringSave ("BLASTN - mrna"); ufp->label = oip; ufp->choice = 2; ufp->data.intvalue = 1; annot->desc = adp; adp = ValNodeNew (NULL); adp->choice = Annot_descr_user; uop = UserObjectNew (); adp->data.ptrvalue = uop; oip = ObjectIdNew (); oip->str = StringSave ("Hist Seqalign"); ufp = UserFieldNew (); uop->type = oip; uop->data = ufp; oip = ObjectIdNew (); oip->str = StringSave ("Hist Seqalign"); ufp->label = oip; ufp->choice = 4; ufp->data.boolvalue = TRUE; adp->next = annot->desc; annot->desc = adp; return annot; }
static void Cn3D_ExportPDB(IteM i) { PDNMS pdnmsThis = NULL; PMSD pmsdThis = NULL; Char pcSavestr[60]; Char pcSavename[32]; CharPtr Cn3D_pcPDBName; GrouP g, g2, g3, g4; GrouP gMS; ButtoN b; if (Cn3D_Export_InUse) return; else Cn3D_Export_InUse = TRUE; pdnmsThis = GetSelectedModelstruc(); if (!pdnmsThis) { Cn3D_Export_InUse = FALSE; return; } pmsdThis = (PMSD) pdnmsThis->data.ptrvalue; Cn3D_wPDBSave = ModalWindow(-20, -13, -10, -10, NULL); /* set up a group encolosing structures - models selection lists and - "info strings" */ Cn3D_pcPDBName = StringSave(GetStrucStrings(pdnmsThis, PDB_ACC)); sprintf(pcSavestr, "Save %s As a PDB Formatted File ...", Cn3D_pcPDBName); g = HiddenGroup(Cn3D_wPDBSave, 0, 3, NULL); SetGroupMargins(g, 10, 10); SetGroupSpacing(g, 10, 5); StaticPrompt(g, pcSavestr, 0, 0, systemFont, 'l'); g2 = HiddenGroup(g, 2, 0, NULL); SetGroupMargins(g2, 10, 10); SetGroupSpacing(g2, 10, 5); StringNCpy(pcSavename, Cn3D_pcPDBName, 8); StringCat(pcSavename, ".pdb"); Cn3D_tPDBSave = DialogText(g2, pcSavename, 18, (TxtActnProc) Cn3D_PDBEnableProc); MemFree(Cn3D_pcPDBName); Cn3D_bPDBBrowse = PushButton(g2, " browse...", (BtnActnProc) Cn3D_PDBBrowseProc); g3 = HiddenGroup(g, 2, 0, NULL); gMS = Cn3D_ModelSelect(g3, FALSE); /* no vector models for PDB files saves */ g4 = HiddenGroup(g3, 0, 2, NULL); SetGroupMargins(g4, 10, 10); SetGroupSpacing(g4, 10, 5); Cn3D_bPDBOk = PushButton(g4, "OK", Cn3D_ExportPDBNow); b = PushButton(g4, "Cancel", Cn3D_CancelPDB); Cn3D_PDBEnableProc(NULL); Select(Cn3D_bPDBOk); /* disable appropriate stuff here */ Cn3D_DisableFileOps(); Show(Cn3D_wPDBSave); return; }
static SeqEntryPtr s_ID1ArchSeqEntryGet (Int4 uid, CharPtr db, Int4 ent,Int4Ptr status, Int2 maxplex) { ID1serverRequestPtr id1reqp; SeqEntryPtr sep; ID1serverMaxcomplexPtr mcp; ID1serverBackPtr id1bp; if(status) *status=0; id1reqp = ValNodeNew(NULL); id1reqp->choice = ID1serverRequest_getsefromgi; mcp = ID1serverMaxcomplexNew(); id1reqp->data.ptrvalue = mcp; mcp -> gi = uid; mcp -> maxplex = maxplex; if(ent > 0){ mcp->ent = ent; if(db){ mcp->sat=StringSave(db); } } ID1serverRequestAsnWrite (id1reqp, asnout, NULL); AsnIoReset(asnout); ID1serverRequestFree (id1reqp); SeqMgrHoldIndexing(TRUE); id1bp = NetID1servReadAsn(); SeqMgrHoldIndexing(FALSE); if (id1bp == NULL) return NULL; if (id1bp->choice != ID1serverBack_gotseqentry && id1bp->choice != ID1serverBack_gotdeadseqentry) { if(status && id1bp->choice == ID1serverBack_error){ *status = id1bp->data.intvalue; } ID1serverBackFree (id1bp); return NULL; } if (status != NULL){ if (id1bp->choice == ID1serverBack_gotdeadseqentry){ * status = 3; }else{ * status = 0; } } sep = (SeqEntryPtr) (id1bp->data.ptrvalue); id1bp->data.ptrvalue = NULL; /* for clean free */ ID1serverBackFree (id1bp); return sep; }
/***************************************************************************** * * StdDatePrint(dvp) * *****************************************************************************/ NLM_EXTERN CharPtr StdDatePrint(DataValPtr dvp) { Char buf[40]; if ( DatePrint((DatePtr)(dvp->ptrvalue), buf)) return StringSave(buf); else return NULL; }
/****************************************************************** *** * general_id_make(): make SeqIdPtr with SEQID_LOCAL choice * ******************************************************************* ***/ NLM_EXTERN SeqIdPtr general_id_make(CharPtr name, CharPtr dbase) { SeqIdPtr new_id; ObjectIdPtr obj_id; DbtagPtr db_tag; new_id=(SeqIdPtr)ValNodeNew(NULL); new_id->choice = SEQID_GENERAL; db_tag = DbtagNew(); db_tag->db = StringSave(dbase); obj_id = ObjectIdNew(); obj_id->str = StringSave(name); db_tag->tag = obj_id; new_id->data.ptrvalue = db_tag; return new_id; }
static IntBadgPtr GetBadgInfo ( SscBadgPtr sbp, Int2 item ) { IntBadgPtr ibp; if (sbp == NULL || item < 0 || item > 127) return NULL; ibp = sbp->badges [item]; if (ibp != NULL) return ibp; ibp = IntBadgInfoNew (); if (ibp != NULL) { ibp->name = StringSave (" "); ibp->comment = StringSave (" "); } sbp->badges [item] = ibp; return ibp; }
static FetchItemPtr FetchItemNew (CharPtr accn) { FetchItemPtr item; item = (FetchItemPtr) MemNew (sizeof (FetchItemData)); item->id_txt = StringSave (accn); item->sip = SmartGuessMakeId(accn); item->field_values = NULL; item->index_pos = -1; return item; }
/*************************************************************************** * * SPI_ReadFeatureTable reads in a tab-delimited file and converts it * to feature information: * * sequence id name of feature start stop * NM_004377.1 repetitive_region 12 40 * * Masking and other feature information for all mRNAs should be in the * same file; ids not in the mRNA list or unknown feature names will be * ignored. * ***************************************************************************/ static void SPI_ReadFeatureTable(FILE *ifp, SPI_bsinfoPtr spim_head) { Char c; CharPtr fields[5]; Boolean found; Char line[60]; Int4 i; CharPtr ptr; SeqIdPtr sip; SeqLocPtr slp; SPI_bsinfoPtr spim; CharPtr str; ValNode vn; str = ReadALine(line, sizeof(line), ifp); while (str != NULL) { ptr = strtok(str, " \t"); for (i=0; i<4; i++) { fields[i] = StringSave(ptr); ptr = strtok(NULL, " \t"); } if (fields[1] != NULL && !StrCmp(fields[1], "repetitive_region")) { c = *fields[0]; if (IS_ALPHA(c)) sip = SeqIdFromAccessionDotVersion(fields[0]); else { vn.choice = SEQID_GI; vn.data.intvalue = atoi(fields[0]); vn.next = NULL; sip = &vn; } spim = spim_head; found = FALSE; while (!found && spim != NULL) { if (SeqIdIn(sip, spim->bsp->id) == TRUE) found = TRUE; else spim = spim->next; } if (found) { slp = SeqLocIntNew(atoi(fields[2]), atoi(fields[3]), Seq_strand_both, spim->bsp->id); slp->next = spim->lcaseloc; spim->lcaseloc = slp; } } str = ReadALine(line, sizeof(line), ifp); } }
/************************************************************************* *** * gb_id_make(): make the Seq-id for Genbank with tsip->name = name * tsip->acc. * ************************************************************************* ***/ NLM_EXTERN SeqIdPtr gb_id_make(CharPtr name, CharPtr acc) { SeqIdPtr new_id; TextSeqIdPtr tsip; new_id= (SeqIdPtr)ValNodeNew(NULL); new_id->choice = SEQID_GENBANK; tsip = TextSeqIdNew(); if(name) { if(StringLen(name) >3 && IS_ALPHA(name[0])) tsip->name = StringSave(name); } if(acc) { if(StringLen(acc) >3 && IS_ALPHA(acc[0])) tsip->accession = StringSave(acc); } new_id->data.ptrvalue = tsip; return new_id; }
void LIBCALL AlignKinHeader(PDNMS pdnmsThis, FILE *pFile, Boolean master) { Int4 depyear, depday; PMSD pmsdThis = NULL; BiostrucSourcePtr pbssThis = NULL; ValNodePtr pvnThis = NULL; BiostrucHistoryPtr pbshThis = NULL; CharPtr pcAuthors = NULL; if (!pdnmsThis) return; pmsdThis = (PMSD) pdnmsThis->data.ptrvalue; pvnThis = ValNodeFindNext(pmsdThis->pbsBS->descr,NULL,BiostrucDescr_history); if (pvnThis) { pbshThis = (BiostrucHistoryPtr) pvnThis->data.ptrvalue; pbssThis = pbshThis->data_source; } if (!pmsdThis->pcPDBName) pmsdThis->pcPDBName = StringSave("1UNK"); fprintf(pFile,"Alignment Summary\n\n"); if (master) fprintf(pFile,"Master:\n%s\n\n", pmsdThis->pcChemName); else fprintf(pFile,"Slave:\n%s\n\n", pmsdThis->pcChemName); fflush(pFile); fprintf(pFile,"MMDB Accession:\n%ld\n\n", (long) pmsdThis->iMMDBid); fprintf(pFile,"PDB Accession:\n%s\n\n", pmsdThis->pcPDBName); fflush(pFile); if (pbssThis) { depyear = pbssThis->database_entry_date->data[1]; depday = pbssThis->database_entry_date->data[3]; fprintf(pFile,"PDB Deposition:\n%2d-%3s-%02d\n\n", (int) depday, NCBI_months[pbssThis->database_entry_date->data[2]-1], (int) depyear%100); } fprintf(pFile,"Class:\n%s\n\n", pmsdThis->pcPdbClass); fflush(pFile); fprintf(pFile,"Source:\n%s\n\n", pmsdThis->pcPdbSource); fflush(pFile); pcAuthors = AuthorListPDB(pmsdThis->pbsBS) ; if (pcAuthors) { fprintf(pFile,"Authors:\n%s\n\n", pcAuthors); fflush(pFile); MemFree(pcAuthors); } return; }
/*---------------- make a new SeqEntry ------------------------*/ NcbiMimeAsn1Ptr ScreenSequence( NcbiMimeAsn1Ptr pvnNcbi, CharPtr JobID) { BiostrucAlignPtr pbsaStruct = NULL; BiostrucAnnotSetPtr pbsaThis = NULL, pbsaHead = NULL; BiostrucFeatureSetPtr pbsfsThis = NULL; BiostrucFeaturePtr pbsfThis = NULL; SeqEntryPtr sepHead = NULL, sepHeadNew = NULL, sepThis = NULL; /*Char PDBName[Local_max], */ Char Chain, Domain; CharPtr pSegmentSlave; pbsaStruct = pvnNcbi->data.ptrvalue; pbsaThis = pbsaStruct->alignments; pbsfsThis = pbsaThis->features; pbsfThis = pbsfsThis->features; StringNCpy(pSegmentMaster, pbsfThis->name, 6); /* StringNCpy(PDBName, pSegmentMaster, 4); */ Chain = pSegmentMaster[4]; sepHead = pbsaStruct->sequences; /*if(JobID){ sepThis = SeqEntryNew(); sepThis->choice = 1; sepThis->data.ptrvalue = sepHead->data.ptrvalue; } else */ sepThis = ExtractThisSep(sepHead, Chain); ValNodeLink(&sepHeadNew, sepThis); sepHead = sepHead->next; while(pbsfThis){ pSegmentSlave = StringSave(&pbsfThis->name[7]); pSegmentSlave[6]='\0'; /*StringNCpy(PDBName, pSegmentSlave, 4);*/ Chain = pSegmentSlave[4]; sepThis = ExtractThisSep(sepHead, Chain); ValNodeLink(&sepHeadNew, sepThis); pbsfThis = pbsfThis->next; sepHead = sepHead->next; } pbsaStruct->sequences = sepHeadNew; MemFree(pSegmentSlave); return(pvnNcbi); }
BEDataPtr BEMakeCLParam(void) { BEDataPtr pBdata; FILE *fd; if (!GetArgs ("qserver", NUMARGS, BE_args)) return NULL; if(!ErrSetLogfile (BE_args[7].strvalue, ELOG_APPEND)) exit(1); pBdata = (BEDataPtr)MemNew(sizeof(BEData)); pBdata->database = BE_args[0].intvalue; pBdata->format = BE_args[1].intvalue; pBdata->allset = BE_args[2].intvalue; pBdata->html = (Uchar) BE_args[3].intvalue; pBdata->query = StringSave(BE_args[4].strvalue); if(BE_args[5].strvalue != NULL) pBdata->uids = StringSave(BE_args[5].strvalue); else if(BE_args[4].strvalue == NULL) { fd = FileOpen(BE_args[6].strvalue, "r"); pBdata->uids = WWWReadFileInMemory(fd, 0, FALSE); FileClose(fd); } pBdata->commandline = TRUE; if(pBdata->query == NULL && pBdata->uids == NULL) { MemFree(pBdata); ErrPostEx(SEV_ERROR, 88, 0, "Error in reading parameters. " "Please check, that query string was set\n"); return NULL; } return pBdata; }
/* This constructs an ASN.1 SeqGraph that contains the quality scores from the consensus sequence */ static SeqGraphPtr SeqGraphFromContig (TContigPtr contig, BioseqPtr bsp) { SeqGraphPtr sgp; ByteStorePtr bs; Uint1 bytes[128]; Int2 max = INT2_MIN; Int2 min = INT2_MAX; Int4 q_pos, b_pos; SeqIntPtr sintp; if (contig == NULL || contig->num_qual_scores == 0 || contig->qual_scores == NULL || bsp == NULL) { return NULL; } sgp = SeqGraphNew (); bs = BSNew (1000); q_pos = 0; while (q_pos < contig->num_qual_scores) { b_pos = 0; while (b_pos < sizeof (bytes) && q_pos < contig->num_qual_scores) { max = MAX (max, (Int2) contig->qual_scores[q_pos]); min = MIN (min, (Int2) contig->qual_scores[q_pos]); bytes[b_pos++] = (Uint1) contig->qual_scores[q_pos++]; } BSWrite (bs, (Pointer) bytes, (Int4) b_pos); } sgp->numval = BSLen (bs); BSPutByte (bs, EOF); sgp->title = StringSave ("Phrap Quality"); sgp->flags [0] = 0; sgp->compr = 1; sgp->flags [1] = 0; sgp->flags [2] = 3; sgp->axis.intvalue = 0; sgp->min.intvalue = min; sgp->max.intvalue = max; sgp->a = 1.0; sgp->b = 0; sgp->values = (Pointer) bs; sintp = SeqIntNew (); sintp->from = 0; sintp->to = bsp->length - 1; sintp->id = SeqIdDup (bsp->id); ValNodeAddPointer (&(sgp->loc), SEQLOC_INT, (Pointer) sintp); return sgp; }
static void AsnLexTAddComment(CharPtr cbeg, CharPtr cend, AsnIoPtr aip) { Char tchar; CharPtr comment; DataVal dv; tchar = *cend; *cend = '\0'; comment = StringSave(cbeg); *cend = tchar; dv.ptrvalue = comment; AsnIoOptionNew(aip, OP_COMMENT, 0, dv, NULL); return; }
static ValNodePtr ValNodeCopyCharPtr (ValNodePtr v1) { ValNodePtr vhead, v2; vhead = v2 = NULL; while (v1 != NULL) { v2 = ValNodeNew (vhead); if (vhead == NULL) vhead = v2; v2->data.ptrvalue = StringSave (v1->data.ptrvalue); v1 = v1->next; } return vhead; }
static ValNodePtr CollectBioSourceValues (BioSourcePtr biop, ValNodePtr field_list) { Char taxid_buf[30]; ValNodePtr field_values = NULL; CharPtr txt; sprintf (taxid_buf, "%d", GetTaxIdFromOrgRef(biop->org)); ValNodeAddPointer (&field_values, 0, StringSave (taxid_buf)); while (field_list != NULL) { txt = GetSourceQualFromBioSource (biop, field_list->data.ptrvalue, NULL); ValNodeAddPointer (&field_values, 0, txt); field_list = field_list->next; } return field_values; }
static XOSPtr SetUp (void) { static GatherScope gs; GatherScopePtr gsp; XOSPtr xosp; gsp = &gs; MemSet ((Pointer) gsp, 0, sizeof (GatherScope)); MemSet ((Pointer) gsp->ignore, (int) (TRUE), (size_t) (OBJ_MAX * sizeof (Boolean))); gsp->ignore[OBJ_BIOSEQ] = FALSE; gsp->ignore[OBJ_SEQANNOT] = FALSE; xosp = MemNew (sizeof (XOS)); xosp->flagParamWindow = FALSE; xosp->gi = 0; xosp->filename = NULL; xosp->gsp = gsp; xosp->sep = NULL; xosp->bsp = NULL; xosp->pattern_file = StringSave ("ncbipros.dat"); xosp->gcd = NULL; xosp->gcdi = NULL; xosp->orfcut = 150; xosp->cutoff = 18; xosp->cutoffmin = 0; xosp->cutoffmax = 100; xosp->window = 360; xosp->windowmin = 150; xosp->windowmax = 3000; xosp->orflist = NULL; xosp->slpa = NULL; xosp->slpb = NULL; xosp->slps = NULL; xosp->slpk = NULL; xosp->probcut = 0.5; xosp->clustmin = 2; xosp->findmin = 4; xosp->minimumseed = 1800; return xosp; }
static Pointer DialogToEndPoint (DialoG d) { ValNodePtr ephead, eplist, vnp; TagListPtr tlp; ephead = eplist = NULL; tlp = (TagListPtr) GetObjectExtra (d); if (tlp != NULL && tlp->vnp != NULL) { for (vnp = tlp->vnp; vnp != NULL; vnp = vnp->next) { eplist = ValNodeNew (ephead); if (ephead == NULL) ephead = eplist; eplist->data.ptrvalue = StringSave ((CharPtr) vnp->data.ptrvalue); } } return ephead; }
static void DoNewFastaDefline ( BioseqPtr bsp, Pointer userdata ) { BioseqSetPtr bssp; CSpeedFlagPtr cfp; Char id [128]; CharPtr title; if (bsp == NULL) return; cfp = (CSpeedFlagPtr) userdata; if (cfp == NULL) return; if (StringChr (cfp->skip, 's') != NULL) { if (bsp->idx.parenttype == OBJ_BIOSEQSET) { bssp = (BioseqSetPtr) bsp->idx.parentptr; if (bssp != NULL) { if (bssp->_class == BioseqseqSet_class_segset || bssp->_class == BioseqseqSet_class_parts) return; } } } if (StringChr (cfp->skip, 'v') != NULL) { if (bsp->repr == Seq_repr_virtual) return; } id [0] = '\0'; SeqIdWrite (bsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1); title = NewCreateDefLine (NULL, bsp, FALSE, FALSE); if (StringHasNoText (title)) { title = StringSave ("?"); } if (cfp->ofp != NULL) { fprintf (cfp->ofp, ">%s %s\n", id, title); } MemFree (title); }
static ValNodePtr FieldsFromFieldListString (CharPtr str) { CharPtr cpy, val, comma; Int4 qual; ValNodePtr field_list = NULL, qc; if (StringHasNoText (str)) { return NULL; } cpy = StringSave (str); val = cpy; comma = StringChr(val, ','); while (comma != NULL) { *comma = 0; qual = GetSourceQualTypeByName(val); if (qual < 0) { Message (MSG_ERROR, "%s is not a recognized source field name", val); } else { qc = ValNodeNew (NULL); qc->choice = SourceQualChoice_textqual; qc->data.intvalue = qual; ValNodeAddPointer (&field_list, FieldType_source_qual, qc); } *comma = ','; val = comma + 1; comma = StringChr (val, ','); } qual = GetSourceQualTypeByName(val); if (qual < 0) { Message (MSG_ERROR, "%s is not a recognized source field name", val); } else { qc = ValNodeNew (NULL); qc->choice = SourceQualChoice_textqual; qc->data.intvalue = qual; ValNodeAddPointer (&field_list, FieldType_source_qual, qc); } cpy = MemFree (cpy); return field_list; }
static void ReadFileProc (ButtoN b) { XOSPtr xosp; Char filename[PATH_MAX]; if ((xosp = (XOSPtr) GetObjectExtra (b)) != NULL) { if (!GetInputFileName (filename, PATH_MAX, "", "TEXT")) { ErrPostEx (SEV_ERROR, TOP_ERROR, 101, "Could not read directory"); ErrShow (); } else { MemFree (xosp->filename); xosp->filename = StringSave (filename); xosp->gi = 0; } } return; }
static void DoFastaComp ( BioseqPtr bsp, Pointer userdata, Boolean ignoreExisting ) { Char buf [4096]; CSpeedFlagPtr cfp; Char id [128]; CharPtr title; if (bsp == NULL) return; cfp = (CSpeedFlagPtr) userdata; if (cfp == NULL) return; id [0] = '\0'; SeqIdWrite (bsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1); buf [0] = '\0'; CreateDefLineExEx (NULL, bsp, buf, sizeof (buf) - 1, 0, NULL, NULL, ignoreExisting, FALSE); title = NewCreateDefLine (NULL, bsp, ignoreExisting, FALSE); if (StringHasNoText (title)) { title = StringSave ("?"); } if (StringCmp (buf, title) != 0) { if (cfp->ofp != NULL) { fprintf (cfp->ofp, "< %s %s\n", id, buf); fprintf (cfp->ofp, "> %s %s\n", id, title); } printf ("< %s %s\n", id, buf); printf ("> %s %s\n", id, title); fflush (stdout); } MemFree (title); }