static void addSubstitution (Alteration *currAlteration, char* proteinSequenceBeforeIndel, char *proteinSequenceAfterIndel, int indelOffset) { int lengthBefore,lengthAfter; static Stringa buffer = NULL; int i; int diff; int index; stringCreateClear (buffer,100); index = ((currAlteration->relativePosition - 1) / 3); lengthBefore = strlen (proteinSequenceBeforeIndel); lengthAfter = strlen (proteinSequenceAfterIndel); diff = abs (lengthBefore - lengthAfter); if (lengthBefore < lengthAfter) { stringPrintf (buffer,"%d_%c->",index + 1,proteinSequenceBeforeIndel[index]); for (i = 0; i <= diff; i++) { stringAppendf (buffer,"%c",proteinSequenceAfterIndel[index + i]); } } else if (lengthBefore > lengthAfter) { stringPrintf (buffer,"%d_",index + 1); for (i = 0; i <= diff; i++) { stringAppendf (buffer,"%c",proteinSequenceBeforeIndel[index + i]); } stringAppendf (buffer,"->%c",proteinSequenceAfterIndel[index]); } else { stringPrintf (buffer,"%d_%s->",index,subString (proteinSequenceBeforeIndel,index - 1,index + (int)ceil ((double)indelOffset / 3))); stringAppendf (buffer,"%s",subString (proteinSequenceAfterIndel,index - 1,index + (int)ceil ((double)indelOffset / 3))); } currAlteration->substitution = hlr_strdup (string (buffer)); }
/** * Prints currSeq to char*. */ char* fastq_printOneSequence (Fastq* currFQ) { static Stringa buffer=NULL; stringCreateClear( buffer, 100 ); stringPrintf( buffer, "@%s\n%s\n+\n%s", currFQ->seq->name, currFQ->seq->sequence, currFQ->quality ); return string( buffer ); }
/** * Generates a link to the PDB. * Example: http://www.rcsb.org/pdb/explore/explore.do?structureId=1HDC */ char* htmlLinker_generateLinkToPDB (char* pdbId) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://www.rcsb.org/pdb/explore/explore.do?structureId=%s",pdbId); return string (buffer); }
/** * Generates a link to PubMed. * Example: http://www.ncbi.nlm.nih.gov/pubmed/18276894 */ char* htmlLinker_generateLinkToPubmed (char* pmid) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://www.ncbi.nlm.nih.gov/pubmed/%s",pmid); return string (buffer); }
/** * Generates a link to EntrezGene. * Example: http://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=search&term=NP_001069323 or http://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=search&term=1812 */ char* htmlLinker_generateLinkToEntrezGene (char* term) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=search&term=%s",term); return string (buffer); }
/** * Generates a link to InterPro. * Example: http://www.ebi.ac.uk/interpro/DisplayIproEntry?ac=IPR001922 */ char* htmlLinker_generateLinkToInterPro (char* interProId) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://www.ebi.ac.uk/interpro/DisplayIproEntry?ac=%s",interProId); return string (buffer); }
/** * Generates a link to Pfam. * Example: http://pfam.sanger.ac.uk/family?acc=PF09582 */ char* htmlLinker_generateLinkToPfam (char* pfamId) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://pfam.sanger.ac.uk/family?acc=%s",pfamId); return string (buffer); }
/** * Generates a link to Saccharomyces Genome Database (SGD) gene description page. * Both the SGD gene ID or the gene symbol can be used. * Example: http://db.yeastgenome.org/cgi-bin/locus.pl?locus=AAC3 or http://db.yeastgenome.org/cgi-bin/locus.pl?locus=S000000289 */ char* htmlLinker_generateLinkToYeastGeneDescriptionPage (char* sgdId) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://db.yeastgenome.org/cgi-bin/locus.pl?locus=%s",sgdId); return string (buffer); }
/** * Generates a link to Rat Genome Database (RGD) gene description page. * Example: http://rgd.mcw.edu/tools/genes/genes_view.cgi?id=727972 * @note The rgdId must be numeric. */ char* htmlLinker_generateLinkToRatGeneDescriptionPage (char* rgdId) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://rgd.mcw.edu/tools/genes/genes_view.cgi?id=%s",rgdId); return string (buffer); }
char* htmlLinker_generateLinkToMouseGeneDescriptionPage (char* mgiId) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://www.informatics.jax.org/searches/accession_report.cgi?id=%s",mgiId); return string (buffer); }
/** * Generates a link to Uniprot. * Example: http://www.pir.uniprot.org/cgi-bin/upEntry?id=Q91V24 or http://www.pir.uniprot.org/cgi-bin/upEntry?id=ADA1A_BOVIN */ char* htmlLinker_generateLinkToUniProt (char* uniProtId) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://www.pir.uniprot.org/cgi-bin/upEntry?id=%s",uniProtId); return string (buffer); }
/** * Generates a link to WormBase gene description page. * Both the WormBase gene ID or the gene symbol can be used. * Example: http://www.wormbase.org/db/gene/gene?name=WBGene00002239 or http://www.wormbase.org/db/gene/gene?name=ksr-1 */ char* htmlLinker_generateLinkToWormBaseGeneDescriptionPage (char* wormBaseGeneId) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://www.wormbase.org/db/gene/gene?name=%s",wormBaseGeneId); return string (buffer); }
/** * Generates a link to AmiGO. * Example: http://amigo.geneontology.org/cgi-bin/amigo/term-details.cgi?term=GO:0051240 */ char* htmlLinker_generateLinkToAmiGO (char* goId) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://amigo.geneontology.org/cgi-bin/amigo/term-details.cgi?term=%s",goId); return string (buffer); }
/** * Generates a link to FlyBase gene description page. * Example: http://flybase.bio.indiana.edu/reports/FBgn0033837.html */ char* htmlLinker_generateLinkToFlyBaseGeneDescriptionPage (char* flyBaseId) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://flybase.bio.indiana.edu/reports/%s.html",flyBaseId); return string (buffer); }
/** * Generates a link to the Yale human pseudogene site. * Example: http://tables.pseudogene.org/human/200550 */ char* htmlLinker_generateLinkToHumanPseudogenePageAtYale (char* pseudogeneId) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://tables.pseudogene.org/human/%s",pseudogeneId); return string (buffer); }
int main (int argc, char *argv[]) { int i,j; Array intervals; Interval *currInterval; SubInterval *currSubInterval; Stringa sizes =NULL; Stringa starts=NULL; if (argc < 2) { usage ("%s <trackName> [simple]",argv[0]); } if( (argc==3) && !strEqual( argv[2],"simple") ) { usage("%s <trackName> [simple]",argv[0]); } intervalFind_addIntervalsToSearchSpace ("-",0); intervals = intervalFind_getAllIntervals (); puts ("browser hide all"); printf ("track name=\"%s\" visibility=2\n",argv[1]); for (i = 0; i < arrayMax (intervals); i++) { currInterval = arrp (intervals,i,Interval); if( argc == 3 ) { for (j = 0; j < arrayMax (currInterval->subIntervals); j++) { currSubInterval = arrp (currInterval->subIntervals,j,SubInterval); printf ("%s\t%d\t%d\t%s_%d\t900\t%c\t%d\t%d\t.\t1\t%d\t0\n", currInterval->chromosome,currSubInterval->start,currSubInterval->end,currInterval->name,j+1,currInterval->strand, currSubInterval->start, currSubInterval->end, currSubInterval->end - currSubInterval->start ); } } else { stringCreateClear( starts, 10); stringCreateClear( sizes, 10); for( j = 0; j < arrayMax (currInterval->subIntervals); j++) { currSubInterval = arrp (currInterval->subIntervals,j,SubInterval); stringAppendf( sizes, "%d", currSubInterval->end - currSubInterval->start ); stringAppendf( starts, "%d", currSubInterval->start - currInterval->start ); if( j<arrayMax( currInterval->subIntervals) ) { stringAppendf( sizes, "," ); stringAppendf(starts, "," ); } } printf ("%s\t%d\t%d\t%s\t900\t%c\t%d\t%d\t.\t%d\t%s\t%s\n", currInterval->chromosome,currInterval->start,currInterval->end, currInterval->name,currInterval->strand, currInterval->start, currInterval->end, currInterval->subIntervalCount, string(sizes), string(starts) ); } } return 0; }
/** * Generates a link to KnownGene description page. * Example: http://genome.ucsc.edu/cgi-bin/hgGene?db=rn4&hgg_gene=NM_012824&hgg_chrom=chr1&hgg_start=78996678&hgg_end=78999875 */ char* htmlLinker_generateLinkToGeneDescriptionPageAtUCSC (char* database, char* geneName, char* chromosome, int start, int end) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://genome.ucsc.edu/cgi-bin/hgGene?db=%s&hgg_gene=%s&hgg_chrom=%s&hgg_start=%d&hgg_end=%d", database,geneName,chromosome,start,end); return string (buffer); }
/** * Generates a link to the UCSC genome browser. * Example: http://genome.ucsc.edu/cgi-bin/hgTracks?db=mm9&clade=vertebrate&org=Mouse&position=chr12:10000-20000 */ char* htmlLinker_generateLinkToGenomeBrowserAtUCSC (char* database, char* clade, char* organism, char* chromosome, int start, int end) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://genome.ucsc.edu/cgi-bin/hgTracks?db=%s&clade=%s&org=%s&position=%s:%d-%d", database,clade,organism,chromosome,start,end); return string (buffer); }
/** * Generates a link to the UCSC track element description page. * Example: http://genome.ucsc.edu/cgi-bin/hgc?db=hg18&g=intronEst&i=BI755927&c=chrX&l=149673899&r=152783129 */ char* htmlLinker_generateLinkToTrackElementDescriptionPageAtUCSC (char* database, char* trackName, char* elementName, char* chromosome, int start, int end) { static Stringa buffer = NULL; stringCreateClear (buffer,100); stringPrintf (buffer,"http://genome.ucsc.edu/cgi-bin/hgc?db=%s&g=%s&i=%s&c=%s&l=%d&r=%d", database,trackName,elementName,chromosome,start,end); return string (buffer); }
static char* processString (char *str) { static Stringa buffer = NULL; Texta tokens; int i; if (!strchr (str,'|')) { return str; } stringCreateClear (buffer,100); tokens = textStrtokP (str,"|"); for (i = 0; i < arrayMax (tokens); i++) { stringAppendf (buffer,"%s%s",textItem (tokens,i),i < arrayMax (tokens) - 1 ? "<br>" : ""); } return string (buffer); }
static char* getBreakPointSequence (char *tileCoordinate1, char *tileCoordinate2) { Stringa buffer; Stringa targetsFile; FILE *fp; Array targetSeqs; int i; Seq *currSeq; static Stringa sequence = NULL; buffer = stringCreate (100); targetsFile = stringCreate (100); stringPrintf (targetsFile,"targets_%d.txt",getpid ()); if (!(fp = fopen (string (targetsFile),"w")) ){ die ("Unable to open target file: %s",string (targetsFile)); } fprintf (fp,"%s\n%s",tileCoordinate1,tileCoordinate2); fclose (fp); stringPrintf (buffer,"%s %s/%s stdout -noMask -seqList=%s", confp_get(Conf, "BLAT_TWO_BIT_TO_FA"), confp_get(Conf, "BLAT_DATA_DIR"), confp_get(Conf, "BLAT_TWO_BIT_DATA_FILENAME"), string (targetsFile)); fasta_initFromPipe (string (buffer)); targetSeqs = fasta_readAllSequences (0); fasta_deInit (); if (arrayMax (targetSeqs) != 2) { die ("Expected only two target sequences"); } stringCreateClear (sequence,100); for (i = 0; i < arrayMax (targetSeqs); i++) { currSeq = arrp (targetSeqs,i,Seq); stringAppendf (sequence,"%s",currSeq->sequence); hlr_free (currSeq->name); hlr_free (currSeq->sequence); } arrayDestroy (targetSeqs); stringPrintf (buffer,"rm -rf %s",string (targetsFile)); hlr_system (string (buffer),0); stringDestroy (targetsFile); stringDestroy (buffer); return string (sequence); }
static void createGffEntry( Array gffEntries, MrfRead *currRead, int groupNumber ) { int i; MrfBlock *currBlock; GffEntry *currGffEntry; static Stringa buffer = NULL; stringCreateClear (buffer,100); for (i = 0; i < arrayMax (currRead->blocks); i++) { currBlock = arrp (currRead->blocks,i,MrfBlock); currGffEntry = arrayp (gffEntries,arrayMax (gffEntries),GffEntry); stringPrintf (buffer,"%s\tMRF\texon\t%d\t%d\t.\t.\t.\tTG%d", currBlock->targetName, currBlock->targetStart, currBlock->targetEnd, //currBlock->strand, groupNumber); currGffEntry->targetName = hlr_strdup (currBlock->targetName); currGffEntry->line = hlr_strdup (string (buffer)); } }
int seqspec_readList (char *wildseq) { /** Do EMBOSS-sytle listfile expansion on 'wildseq'.<br> Postcondition: seqspec_iterInit() can be called @param[in] wildseq - a wildcrd sequence specification @return number of sequence-specifing lines recognized */ /* in EMBOSS there are two sorts of 'wildcarding': (1) thru joker characters (*, ?) (2) thru file inclusion (@file) this function re-implements the @file resolution */ seqCnt = 0; seqspecsInitClear (); stringCreateClear (fileNames,100); readList (wildseq); return seqCnt; }
int seqspec_split2continous (Seqspec this1) { /** If 'this1' sequence segment is of the form 'db:seq_n begin:b end:e' it is transformed into 'db:seq begin:b1 end:e1' where b1=b+n*100000, e1=e+n*100000 which means the GCG type split is removed @param[in] this1 - the Seqspec object @param[out] this1 - the Seqspec object possibly modified @return 1 if 'this1' changed, else 0 */ static char *seqname = NULL; static Stringa dbseqname = NULL; int nameLen; char *cp; int offset; int segnum; stringCreateClear (dbseqname,40); strReplace (&seqname,this1->seqname); nameLen = strlen (seqname); if (nameLen < 3) return 0; if ((cp = strrchr(seqname, '_')) == NULL) return 0; if (*(cp+1) == '\0' || strlen (cp+1) > 2) return 0; segnum = atoi (cp+1); *cp = 0; offset = segnum * FRAGMENT_LENGTH; this1->begin += offset; if (this1->end != 0) this1->end += offset; stringCpy (dbseqname,this1->dbname); stringCat (dbseqname,":"); stringCat (dbseqname,seqname); seqspec_IDset (this1,string (dbseqname)); return 1; }
Seqspec seqspec_parseLine (char *line) { /** Parses line into a sequence segment; @param[in] line - something that can be parsed into a Seqspec object @return NULL if line could not be parsed, else pointer to a Seqspec object. This object is read-only to its users */ static Seqspec seqspec = NULL; char *cp; char *value; int t; char c; int blankSkip; int strandSeen = 0; static Stringa s = NULL; if (seqspec == NULL) seqspec = seqspec_create (); stringCreateClear(s,30); // remove leading blanks and blanks after ':' blankSkip = 1; cp = line - 1; while ((c = *++cp) != '\0') { if (isspace (c)) { if (blankSkip) continue; } else if (c == ':') blankSkip = 1; else blankSkip = 0; stringCatChar (s,c); } wordSet (string (s)," \t"); if ((cp = wordGet ()) == NULL) return NULL; if (!seqspec_IDset (seqspec,cp)) return NULL; seqspec->begin = 1; seqspec->end = SEQSPEC_END; seqspec->revcompF = 0; // loop over remaining words of line while ((cp = wordGet ()) != NULL) { if (!(value = dbseqDissect (cp))) continue; if (strCaseEqual (cp,"begin")) seqspec->begin = atoi (value); if (strCaseEqual (cp,"end")) seqspec->end = atoi (value); if (strCaseEqual (cp,"strand")) seqspec->revcompF = (*value == '-'); } if (seqspec->begin <= 0) return NULL; if (seqspec->end != SEQSPEC_END) { // treat e.g. begin:30 end:20 as revcomp if (seqspec->end < seqspec->begin) { if (strandSeen) { warn ("seqspec: bad segment syntax at %s",seqspec->dbseqname); return NULL; } t = seqspec->end; seqspec->end = seqspec->begin; seqspec->begin = t; seqspec->revcompF = 1; } } return seqspec; }