/***************************************************************************** * * StdAuthListNamesPrint(dvp) * prints just Auth-list.names to a string * *****************************************************************************/ NLM_EXTERN CharPtr StdAuthListNamesPrint(DataValPtr dvp) { AuthListPtr alp; Boolean first = TRUE; ValNodePtr vnp; PersonIdPtr pip; AuthorPtr ap; ByteStorePtr bsp; CharPtr str; Char buf[60]; if (dvp == NULL) return NULL; alp = (AuthListPtr)(dvp->ptrvalue); if (alp == NULL) return NULL; bsp = BSNew(80); for (vnp = alp->names; vnp != NULL; vnp = vnp->next) { if (! first) /* separators for names after first one */ { if (vnp->next != NULL) BSPutByte(bsp, (Int2)','); else { BSPutByte(bsp, (Int2)' '); BSPutByte(bsp, (Int2)'&'); } BSPutByte(bsp, (Int2)' '); } first = FALSE; if (alp->choice == 3 || alp->choice == 2) /* ml or str */ { BSWrite(bsp, vnp->data.ptrvalue, (Int4)(StringLen((CharPtr)(vnp->data.ptrvalue)))); } else if (alp->choice == 1) /* std */ { ap = (AuthorPtr) (vnp->data.ptrvalue); if (ap != NULL) { pip = ap->name; PersonIdPrint(pip, buf); BSWrite(bsp, buf, (Int4)StringLen(buf)); } else BSPutByte(bsp, (Int2)'?'); } } str = BSMerge(bsp, NULL); BSFree(bsp); return str; }
void LIBCALL FlushItems (PostingPtr pst) { if (pst != NULL && pst->uids != NULL && pst->buffer != NULL) { BSWrite (pst->uids, pst->buffer, pst->count); if (pst->buffer != NULL) { pst->buffer = MemFree (pst->buffer); } pst->count = 0; pst->index = 0; } }
/***************************************************************************** * * ByteStorePtr AsnLexReadOctets(aip, atp) * expects Octets type next * assumes none of it has already been read * does not advance to next token * atp points to the definition of this OCTET STRING * *****************************************************************************/ NLM_EXTERN ByteStorePtr AsnLexReadOctets (AsnIoPtr aip, AsnTypePtr atp) { Int2 token, len; ByteStorePtr ssp = NULL; Byte tbuf[256]; /* was 101 - changed to handle occasional hand-edited ASN.1? */ Int4 bytes, left, added; token = AsnLexWord(aip); /* read the start */ if (token != START_BITHEX) { AsnIoErrorMsg(aip, 45, AsnErrGetTypeName(atp->name), aip->linenumber); return NULL; } ssp = BSNew(0); if (ssp == NULL) return ssp; token = AsnLexWord(aip); /* read the octet(s) */ left = 0; while (token == IN_BITHEX) { len = (Int2)(aip->wordlen + left); MemCopy((tbuf + left), aip->word, (len - left)); tbuf[len] = '\0'; added = AsnTypeStringToHex(tbuf, len, tbuf, &left); if (added < 0) { AsnIoErrorMsg(aip, 46, AsnErrGetTypeName(atp->name), aip->linenumber); return NULL; } if (added) { bytes = BSWrite(ssp, tbuf, added); if (bytes != added) { ssp = BSFree(ssp); return ssp; } } if (left) /* left a char */ { MemCopy(tbuf, ((aip->word)+(aip->wordlen - left)),left); } token = AsnLexWord(aip); } if (token != OCTETS) { AsnIoErrorMsg(aip, 47, AsnErrGetTypeName(atp->name), aip->linenumber); return NULL; } return ssp; }
/* 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; }
void LIBCALL WriteItem (PostingPtr pst, DocUid value) { if (pst != NULL && pst->uids != NULL) { if (pst->buffer == NULL) { pst->buffer = MemNew ((size_t) pst->bufsize); pst->count = 0; pst->index = 0; } pst->buffer [pst->index] = value; (pst->index)++; (pst->count) += sizeof (DocUid); if (pst->count >= pst->bufsize) { BSWrite (pst->uids, pst->buffer, pst->count); pst->count = 0; pst->index = 0; } } }
static Pointer AsnLexReadStringEx (AsnIoPtr aip, AsnTypePtr atp, Uint1 fix_non_print) { Int2 token; ByteStorePtr ssp; CharPtr result=NULL; Int4 bytes; token = AsnLexWordEx (aip, fix_non_print); /* read the start */ if (token != START_STRING) { AsnIoErrorMsg(aip, 43, AsnErrGetTypeName(atp->name), aip->linenumber); return NULL; } ssp = BSNew(0); if (ssp == NULL) return result; token = AsnLexWordEx (aip, fix_non_print); /* read the string(s) */ while (token == IN_STRING) { bytes = BSWrite(ssp, aip->word, (Int4)aip->wordlen); if (bytes != (Int4)(aip->wordlen)) { BSFree(ssp); return result; } token = AsnLexWord(aip); } if (token == ERROR_TOKEN) return NULL; if (token != END_STRING) { AsnIoErrorMsg(aip, 44, AsnErrGetTypeName(atp->name), aip->linenumber); return NULL; } if (AsnFindBaseIsa(atp) == STRSTORE_TYPE) /* string store */ return ssp; result = (CharPtr) BSMerge(ssp, NULL); BSFree(ssp); return result; }
void InitBSPLog(Int4 randseed,CharPtr sequence,Int4 tstruc) { CharPtr decsequence; static Char pcUname[PATH_MAX]=""; Char timedate[25]; #ifdef OS_UNIX struct utsname utsbuf; #endif bspTempLog=BSNew(0); /* compute log file name */ if (generation==0) sprintf(LogOutName,"%sfold_%ld_%s_%ld_%s",CFG_local_datafilepath,(long)experiment,handle,(long)tstruc,fnamtrj); else sprintf(LogOutName,"%sfold_%ld_%s_%ld_%s_%s_%d",CFG_local_datafilepath,(long)experiment,handle,(long)tstruc,handle,fnamtrj,generation); BSprintf(bspTempLog,"\nFoldtraj v%s log report",FOLDTRAJ_VERSION); BSprintf(bspTempLog,"\nTrajectory File: %s%s_%d",CFG_local_datafilepath,fnamtrj,generation); BSprintf(bspTempLog,"\tStructure File Base Name: %s_%s_%d",handle,fnamtrj,generation); BSprintf(bspTempLog,"\tRandom Seed: %ld\t# Generated: %ld\tStart Numbering at: %ld",randseed,STRUCS_PER_RUN,1); BSprintf(bspTempLog,"\tCompared to Native Structure: 1CDZ"); decsequence=DecodeSequence(sequence,EXTAA_PARENT); BSprintf(bspTempLog,"\nSequence: %s",decsequence); decsequence=MemFree(decsequence); BSprintf(bspTempLog,"\nFolding Conditions:\t%ldx%ld Trajectory Distributions\t%s Random Walk\tAverage Timeout: %ld\tBackbone Error Tolerance: %4.2f\tBackbone Precision: %6.4f\tBackbone Atom Bounciness: %5.2f%%\tSidechain Atom Bounciness: %5.2f %%\tHydrogen Bumpchecking: %s\t# Rotamer Tries: %d/chi angle\tMarkov Scale Factor: %4.2f", TRAJDIV,TRAJDIV,WALKTYPE==WALK_CA?"C-Alpha":"Phi-Psi",TIMEOUT,BACKBONE_ERROR_TOLERANCE, BACKBONE_PRECISION,ATOM_BOUNCINESS_BB*100.0,ATOM_BOUNCINESS_SC*100.0, BUMPCHECK_HYDROGEN?"On":"Off",NUM_ROT_TRIES,MARKOV_SCALE_FACTOR); if (WALKTYPE!=WALK_CA && MARKOV_SCALE_FACTOR>0.0) ErrPostEx(SEV_ERROR,2,2,"Markov Scale Factor should be zero for non-Ca walk -- ignored"); if (TRAJTYPE!=TRAJ_NA) { BSprintf(bspTempLog,"\tTrajectory Distribution: "); switch (TRAJTYPE) { case TRAJ_UNIFORM: BSprintf(bspTempLog,"Uniform"); break; case TRAJ_STANDARD: BSprintf(bspTempLog,"Amino-Acid Based"); break; case TRAJ_SSTRU: BSprintf(bspTempLog,"1-State Secondary Structure Prediction"); break; case TRAJ_GOR: BSprintf(bspTempLog,"3-State Secondary Structure Prediction"); break; default: BSprintf(bspTempLog,"Unknown"); } } if (StringCmp(CONSTRAINT_FILE,"")) BSprintf(bspTempLog,"\tConstraint file: %s",CONSTRAINT_FILE); BSprintf(bspTempLog,"\nSystem Information: "); if (StringLen(pcUname)==0) { StringCpy(pcUname,"Not Available\n"); #ifdef OS_UNIX /* use uname to get sysinfo */ if (uname(&utsbuf)>=0) { sprintf(pcUname,"%s %s %s %s %s\n",utsbuf.sysname,utsbuf.nodename,utsbuf.release,utsbuf.version,utsbuf.machine); } #else #ifdef OS_MSWIN /* assume ver is available */ if (GetMSWinVerInfo(pcUname)!=ERR_SUCCESS) { StringCpy(pcUname,"Not Available\n"); } #endif #endif } BSWrite(bspTempLog,pcUname,StringLen(pcUname)); DayTimeStr(timedate,TRUE,TRUE); BSprintf(bspTempLog,"Job started: %s\n",timedate); BSprintf(bspTempLog,"\nStructure\tTime(s)\tTries\tBad Backbone Tries\tCrashes\tDistant Constraint Tries (# Violations)\tChain Length\tRadius of Gyration(A)\tHydrophobics Radius of Gyration(A)\tEnd-to-end Distance(A)\tRn\tCn"); BSprintf(bspTempLog,"\tSurface Accessibility (A^2)\tExposed Hydrophobics (A^2)"); BSprintf(bspTempLog,"\t# Helical Residues (DSSP)\t# Extended Residues (DSSP)"); BSprintf(bspTempLog,"\t# Extended Residues (CA-CA dist.)"); BSprintf(bspTempLog,"\tRMSD from Native(A)"); BSprintf(bspTempLog,"\tZhang Potential(Exclusive Window Size %d)\tBryant-Lawrence Potential(Exclusive Window Size %d)\tCrease Energy\n",ZHANG_WINDOWSIZE,BRYANT_WINDOWSIZE); }
static void Get_Sequence (FILE *f, SeqRecPtr seqrp) { Char ch; CharPtr chptr; Boolean goOn; IdRecPtr last; Int4 len; Char str [256]; IdRecPtr this; Int4 total; if (f != NULL && seqrp != NULL) { if (seqrp->rawSeq == NULL) { seqrp->rawSeq = BSNew (1000); } if (seqrp->segLens == NULL) { seqrp->segLens = BSNew (10); } len = 0; total = 0; goOn = TRUE; while (goOn && ReadNextLine (f, str, sizeof (str))) { if (str [0] == '&') { goOn = FALSE; } else if (str [0] == '!') { goOn = FALSE; } else if (str [0] == '>') { if (len > 0) { if (seqrp->lookForStop) { BSPutByte (seqrp->rawSeq, (Int2) '*'); len++; } BSWrite (seqrp->segLens, &len, sizeof (Int4)); total += len; len = 0; } chptr = StringChr (str, ' '); if (chptr != NULL) { *chptr = '\0'; } if (seqrp->ids != NULL) { last = seqrp->ids; while (last->next != NULL) { last = last->next; } this = MemNew (sizeof (IdRec)); if (this != NULL) { this->id.accn = StringSave (str + 1); } last->next = this; } else { last = MemNew (sizeof (IdRec)); if (last != NULL) { last->id.accn = StringSave (str + 1); } seqrp->ids = last; } } else if (str [0] != '\0') { chptr = str; while (*chptr != '\0') { ch = TO_UPPER (*chptr); if (ch >= 'A' && ch <= 'Z') { if (seqrp->nuc) { if (ch == 'U') { ch = 'T'; } if (StringChr ("BDEFHIJKLMOPQRSUVWXYZ", ch) == NULL) { BSPutByte (seqrp->rawSeq, (Int2) ch); len++; } } else { if (StringChr ("JOU", ch) == NULL) { BSPutByte (seqrp->rawSeq, (Int2) ch); len++; } } } chptr++; } } } if (seqrp->nuc) { BSPutByte (seqrp->rawSeq, (Int2) 'N'); BSPutByte (seqrp->rawSeq, (Int2) 'N'); BSPutByte (seqrp->rawSeq, (Int2) 'N'); len += 3; } if (len > 0) { if (seqrp->lookForStop) { BSPutByte (seqrp->rawSeq, (Int2) '*'); len++; } BSWrite (seqrp->segLens, &len, sizeof (Int4)); total += len; len = 0; } if (total > 0) { seqrp->sequence = BSMerge (seqrp->rawSeq, NULL); seqrp->length = total; } else { seqrp->sequence = NULL; seqrp->length = 0; } } }