static int isHomologous (Array kgTreeFams, char *transcript1, char *transcript2) { Texta tokens; int i,j; char *treeFamId; static Texta treeFamIdsTranscript1 = NULL; static Texta treeFamIdsTranscript2 = NULL; textCreateClear (treeFamIdsTranscript1,100); textCreateClear (treeFamIdsTranscript2,100); tokens = textFieldtokP (transcript1,"|"); for (i = 0; i < arrayMax (tokens); i++) { if (treeFamId = lookUpTreeFam (kgTreeFams,textItem (tokens,i))) { textAdd (treeFamIdsTranscript1,treeFamId); } } textDestroy (tokens); tokens = textFieldtokP (transcript2,"|"); for (i = 0; i < arrayMax (tokens); i++) { if (treeFamId = lookUpTreeFam (kgTreeFams,textItem (tokens,i))) { textAdd (treeFamIdsTranscript2,treeFamId); } } textDestroy (tokens); for (i = 0; i < arrayMax (treeFamIdsTranscript1); i++) { for (j = 0; j < arrayMax (treeFamIdsTranscript2); j++) { if (strEqual (textItem (treeFamIdsTranscript1,i),textItem (treeFamIdsTranscript2,j))) { return 1; } } } return 0; }
SEXP r_cgiParameters() { int i; char *name; Stringa value=stringCreate(16); Texta keys=textCreate(8); Texta values=textCreate(8); SEXP r_keys, r_values; cgiGetInit(); while(name = cgiGetNext(value)) { textAdd(keys, name); textAdd(values, string(value)); } int n=arrayMax(keys); PROTECT(r_keys=allocVector(STRSXP, n)); PROTECT(r_values=allocVector(STRSXP, n)); for(i=0; i<n; ++i) { SET_STRING_ELT(r_keys, i, mkChar(textItem(keys,i))); SET_STRING_ELT(r_values, i, mkChar(textItem(values,i))); } setNames(r_values, r_keys); stringDestroy(value); textDestroy(keys); textDestroy(values); UNPROTECT(2); return(r_values); }
void TextTool::focusLost() { if (textItem()) { textItem()->writeTextToProperty(); view()->changeToSelectionTool(); } }
QSysMLAction::QSysMLAction(const QMap<QString, QVariant> &properties, QGraphicsItem *parent) : QAbstractDiagramShape(QSysMLPlugin::staticName(), QSysMLAction::staticItemClass(), properties, parent) { initGeometry(400, 300); textItem()->setTextColorProperty("textColor"); textItem()->setTextProperty("name"); textItem()->setDefaultTextAlignment(Qt::AlignCenter); addProperty("actionType", QDiagramToolkit::String, true, properties.value("actionType")); addProperty("background", QDiagramToolkit::Brush, false, properties.value("background", QColor("wheat"))); addProperty("textColor", QDiagramToolkit::Color, false, properties.value("textColor", QColor("black"))); addProperty("textFont", QDiagramToolkit::Font, false, properties.value("textFont")); addProperty("lineStyle", QDiagramToolkit::Pen, false, properties.value("lineStyle")); addProperty("name", QDiagramToolkit::String, false, "action"); addSizeGripHandle(new QDiagramShapeSizeGripHandle(QDiagramShapeSizeGripHandle::Left, this)); addSizeGripHandle(new QDiagramShapeSizeGripHandle(QDiagramShapeSizeGripHandle::Right, this)); addConnectionPoint(new QSysMLControlConnectionPointIn(this, "controlIn", 0, 1)); addConnectionPoint(new QSysMLControlConnectionPointOut(this, "controlOut", 0, 1)); addConnectionPoint(new QSysMLDataConnectionPointIn(this, "dataIn1", 0, 1)); addConnectionPoint(new QSysMLDataConnectionPointOut(this, "dataOut1", 0, 1)); restoreProperties(properties); }
void TextTool::hoverMoveEvent(const QList<QGraphicsItem*> & /*itemList*/, QGraphicsSceneMouseEvent * event) { event->setPos(textItem()->mapFromScene(event->scenePos())); event->setLastPos(textItem()->mapFromScene(event->lastScenePos())); scene()->sendEvent(textItem(), event); }
void TextTool::itemsAboutToRemoved(const QList<FormEditorItem*> &removedItemList) { if (textItem() == 0) return; if (removedItemList.contains(textItem()->formEditorItem())) view()->changeToSelectionTool(); }
void TextTool::instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList) { typedef QPair<ModelNode, PropertyName> ModelNodePropertyNamePair; foreach (const ModelNodePropertyNamePair &propertyPair, propertyList) { if (propertyPair.first == textItem()->formEditorItem()->qmlItemNode().modelNode() && propertyPair.second == "text") textItem()->updateText(); } }
void QSysMLAction::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) { if (event->button() == Qt::LeftButton){ textItem()->setTextWidth(geometry().width()); textItem()->updatePosition(); textItem()->setEditModeEnabled(true); } QAbstractDiagramShape::mouseDoubleClickEvent(event); }
void TextTool::mouseReleaseEvent(const QList<QGraphicsItem*> &itemList, QGraphicsSceneMouseEvent *event) { if (!itemList.contains(textItem())) { textItem()->writeTextToProperty(); view()->changeToSelectionTool(); } AbstractFormEditorTool::mouseReleaseEvent(itemList, event); }
int main (int argc, char *argv[]) { GfrEntry *currGE; int count; int countRemoved; int i; if (argc != 3) { usage ("%s <offsetCutoff> <minNumUniqueReads>",argv[0]); } count = 0; countRemoved = 0; int offsetCutOff = atoi (argv[1]); int minNumUniqueReads = atoi (argv[2]); gfr_init ("-"); puts (gfr_writeHeader ()); while (currGE = gfr_nextEntry ()) { Array starts = arrayCreate( 100, int); for (i = 0; i < arrayMax( currGE->interReads ); i++) { int currStart = arrp(currGE->interReads, i, GfrInterRead)->readStart1 + arrp(currGE->interReads, i, GfrInterRead)->readStart2; array(starts, arrayMax(starts), int) = currStart; } arraySort( starts, (ARRAYORDERF) arrayIntcmp ); arrayUniq( starts, NULL, (ARRAYORDERF) arrayIntcmp ) ; int numUniqeOffsets = arrayMax( starts ); arrayDestroy( starts ); if (arrayMax( currGE->readsTranscript1 ) != arrayMax( currGE->readsTranscript2 ) ) die( "The two ends have a different number of reads"); Texta reads = textCreate(arrayMax(currGE->readsTranscript1)); for (i = 0; i < arrayMax(currGE->readsTranscript1); i++) { Stringa strA = stringCreate( strlen(textItem( currGE->readsTranscript1, i) ) * 2 + 1); stringAppendf( strA, textItem( currGE->readsTranscript1,i)); stringAppendf( strA, textItem( currGE->readsTranscript2,i)); textAdd( reads, string(strA)); stringDestroy( strA ); } textUniqKeepOrder( reads ); int numRemaining = arrayMax( reads ); textDestroy ( reads ); if (numRemaining <= minNumUniqueReads || numUniqeOffsets <= offsetCutOff) { countRemoved++; continue; } puts (gfr_writeGfrEntry (currGE)); count++; } gfr_deInit (); warn("%s_PCRFilter: offset=%d minNumUniqueReads=%d", argv[0],offsetCutOff, minNumUniqueReads); warn("%s_numRemoved: %d",argv[0],countRemoved); warn("%s_numGfrEntries: %d",argv[0],count); return 0; }
void TextTool::keyPressEvent(QKeyEvent *keyEvent) { if (keyEvent->key() == Qt::Key_Escape) { textItem()->writeTextToProperty(); keyEvent->accept(); } else { scene()->sendEvent(textItem(), keyEvent); } }
void Elevator::zeroOccupancy() { mOccupancy = 0; textItem()->hide(); textItem()->setPlainText("0"); centerTextItem(); ellipseItem()->hide(); }
void Elevator::incrementOccupancy() { ++mOccupancy; if ( !textItem()->isVisible() ) textItem()->show(); textItem()->setPlainText( QString::number(mOccupancy) ); if ( !ellipseItem()->isVisible() ) ellipseItem()->show(); centerTextItem(); }
int checkOriginal ( BlatQuery* blQ, PslEntry* entry ) { int res = 0; Texta t = textFieldtokP( blQ->qName, "|"); if( ( strEqual ( textItem( t, 1 ), entry->tName ) ) && ( atoi( textItem( t, 3 ) ) == entry->tStart ) && ( atoi( textItem( t, 4 ) ) == entry->tEnd ) && entry->misMatches==0 && (entry->matches+entry->nCount) == entry->qSize) res = 1; else res = 0; textDestroy( t ); return res; }
QImage *DemoTextItem::createImage(const QMatrix &matrix) const { if (this->type == DYNAMIC_TEXT) return 0; float sx = qMin(matrix.m11(), matrix.m22()); float sy = matrix.m22() < sx ? sx : matrix.m22(); QGraphicsTextItem textItem(0, 0); textItem.setHtml(this->text); textItem.setTextWidth(this->textWidth); textItem.setFont(this->font); textItem.setDefaultTextColor(this->textColor); textItem.document()->setDocumentMargin(2); float w = textItem.boundingRect().width(); float h = textItem.boundingRect().height(); QImage *image = new QImage(int(w * sx), int(h * sy), QImage::Format_ARGB32_Premultiplied); image->fill(QColor(0, 0, 0, 50).rgba()); QPainter painter(image); painter.scale(sx, sy); QStyleOptionGraphicsItem style; textItem.paint(&painter, &style, 0); return image; }
static void printMrfAlignBlocks (SamEntry *e, int _strand) { char strand = '.'; int len, intronic; int q, pos; int i; Texta tokens; tokens = textFieldtokP (e->cigar, "MN"); if (_strand == R_FIRST) { if (e->flags & S_QUERY_STRAND) strand = '-'; else strand = '+'; } else { if (e->flags & S_MATE_STRAND) strand = '-'; else strand = '+'; } // Process first item in cigar len = atoi (textItem (tokens, 0)); pos = e->pos; q = 1; printf ("%s:%c:%d:%d:%d:%d", e->rname, strand, e->pos, pos + len - 1, 1, len); pos += len - 1; q += len; // Process rest of cigar if (arrayMax (tokens) > 2) { for (i = 2; i < arrayMax (tokens) - 1; i += 2) { len = atoi (textItem (tokens, i)); intronic = atoi (textItem (tokens, i - 1)); pos += intronic + 1; printf(",%s:%c:%d:%d:%d:%d", e->rname, strand, pos, pos + len - 1, q, q + len - 1); pos += len - 1; q += len; } } textDestroy (tokens); }
void TextTool::keyReleaseEvent(QKeyEvent *keyEvent) { if (keyEvent->key() == Qt::Key_Escape) { keyEvent->accept(); view()->changeToSelectionTool(); } else { scene()->sendEvent(textItem(), keyEvent); } }
void TextTool::mouseDoubleClickEvent(const QList<QGraphicsItem*> & /*itemList*/, QGraphicsSceneMouseEvent *event) { if (textItem() && !textItem()->boundingRect().contains(textItem()->mapFromScene(event->scenePos()))) { textItem()->writeTextToProperty(); view()->changeToSelectionTool(); } else { event->setPos(textItem()->mapFromScene(event->scenePos())); event->setLastPos(textItem()->mapFromScene(event->lastScenePos())); scene()->sendEvent(textItem(), event); } }
void startConsuming() { if (isConsuming()) return; consumeQueue()->dispatch([this] { CString upper; while (m_upperQueue.dequeue(upper)) { EXPECT_TRUE(upper == toUpper(textItem(m_consumeCount++))); std::this_thread::sleep_for(std::chrono::milliseconds(50)); } m_consumeCloseSemaphore.signal(); }); }
void startProducing() { if (isProducing()) return; produceQueue()->dispatch([this] { CString lower; while (m_lowerQueue.dequeue(lower)) { m_upperQueue.enqueue(toUpper(lower)); EXPECT_TRUE(lower == textItem(m_produceCount++)); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } m_produceCloseSemaphore.signal(); }); }
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); }
TEST(WTF_SynchronizedFixedQueue, ProduceOnly) { ToUpperConverter<4U> converter; converter.startProducing(); EXPECT_TRUE(converter.isProducing() && !converter.isConsuming()); size_t count = 0; while (char const* item = textItem(count)) { converter.enqueueLower(item); ++count; std::this_thread::sleep_for(std::chrono::milliseconds(1)); } converter.stop(); EXPECT_FALSE(converter.isProducing() || converter.isConsuming()); }
void TextTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList) { if (textItem()) { textItem()->writeTextToProperty(); view()->changeToSelectionTool(); } if (!itemList.isEmpty()) { FormEditorItem *formEditorItem = itemList.first(); m_textItem = new TextEditItem(scene()); textItem()->setParentItem(scene()->manipulatorLayerItem()); textItem()->setFormEditorItem(formEditorItem); connect(textItem(), &TextEditItem::returnPressed, [this] { textItem()->writeTextToProperty(); view()->changeToSelectionTool(); }); } else { view()->changeToSelectionTool(); } }
int main (int argc, char *argv[]) { Array intervals; Interval *currInterval; SubInterval *currSubInterval; int refLength,altLength,offset; int h,i,j; Stringa buffer; Array geneTranscriptEntries; Texta geneTranscriptIds; Array alterations; Alteration *currAlteration,*nextAlteration; int numTranscripts; Stringa transcripts; VcfEntry *currVcfEntry; int position; Texta alternateAlleles; int flag1,flag2; VcfGenotype *currVcfGenotype; if (argc != 3) { usage ("%s <annotation.interval> <nameFeature>",argv[0]); } intervalFind_addIntervalsToSearchSpace (argv[1],0); geneTranscriptEntries = util_getGeneTranscriptEntries (intervalFind_getAllIntervals ()); buffer = stringCreate (100); transcripts = stringCreate (100); alterations = arrayCreate (100,Alteration); vcf_init ("-"); stringPrintf (buffer,"##INFO=<ID=VA,Number=.,Type=String,Description=\"Variant Annotation, %s, %s\">",argv[1],argv[2]); vcf_addComment (string (buffer)); puts (vcf_writeMetaData ()); puts (vcf_writeColumnHeaders ()); while (currVcfEntry = vcf_nextEntry ()) { if (vcf_isInvalidEntry (currVcfEntry)) { continue; } flag1 = 0; flag2 = 0; position = currVcfEntry->position - 1; // make zero-based alternateAlleles = vcf_getAlternateAlleles (currVcfEntry); for (h = 0; h < arrayMax (alternateAlleles); h++) { refLength = strlen (currVcfEntry->referenceAllele); altLength = strlen (textItem (alternateAlleles,h)); offset = MAX (refLength,altLength) - 1; util_clearAlterations (alterations); intervals = intervalFind_getOverlappingIntervals (currVcfEntry->chromosome,position,position + offset); for (i = 0; i < arrayMax (intervals); i++) { currInterval = arru (intervals,i,Interval*); j = 0; while (j < arrayMax (currInterval->subIntervals)) { currSubInterval = arrp (currInterval->subIntervals,j,SubInterval); if (currSubInterval->start <= position && (position + offset) < currSubInterval->end) { break; } j++; } if (j == arrayMax (currInterval->subIntervals)) { continue; } util_addAlteration (arrayp (alterations,arrayMax (alterations),Alteration),currInterval->name,argv[2],currInterval,position,0); } if (arrayMax (alterations) == 0) { continue; } arraySort (alterations,(ARRAYORDERF)util_sortAlterationsByGeneIdAndType); stringClear (buffer); i = 0; while (i < arrayMax (alterations)) { currAlteration = arrp (alterations,i,Alteration); stringAppendf (buffer,"%s%d:%s:%s:%c:%s",stringLen (buffer) == 0 ? "" : "|",h + 1,currAlteration->geneName,currAlteration->geneId,currAlteration->strand,currAlteration->type); stringClear (transcripts); stringAppendf (transcripts,"%s:%s:%d_%d",currAlteration->transcriptName,currAlteration->transcriptId,currAlteration->transcriptLength,currAlteration->relativePosition); numTranscripts = 1; j = i + 1; while (j < arrayMax (alterations)) { nextAlteration = arrp (alterations,j,Alteration); if (strEqual (currAlteration->geneId,nextAlteration->geneId) && strEqual (currAlteration->type,nextAlteration->type)) { stringAppendf (transcripts,":%s:%s:%d_%d",nextAlteration->transcriptName,nextAlteration->transcriptId,nextAlteration->transcriptLength,nextAlteration->relativePosition); numTranscripts++; } else { break; } j++; } i = j; geneTranscriptIds = util_getTranscriptIdsForGeneId (geneTranscriptEntries,currAlteration->geneId); stringAppendf (buffer,":%d/%d:%s",numTranscripts,arrayMax (geneTranscriptIds),string (transcripts)); } if (flag1 == 0) { printf ("%s\t%d\t%s\t%s\t%s\t%s\t%s\t%s;VA=", currVcfEntry->chromosome,currVcfEntry->position,currVcfEntry->id, currVcfEntry->referenceAllele,currVcfEntry->alternateAllele, currVcfEntry->quality,currVcfEntry->filter,currVcfEntry->info); flag1 = 1; } printf ("%s%s",flag2 == 1 ? "," : "",string (buffer)); flag2 = 1; } if (flag1 == 1) { for (i = 0; i < arrayMax (currVcfEntry->genotypes); i++) { currVcfGenotype = arrp (currVcfEntry->genotypes,i,VcfGenotype); if (i == 0) { printf ("\t%s\t",currVcfEntry->genotypeFormat); } printf ("%s%s%s%s",currVcfGenotype->genotype, currVcfGenotype->details[0] != '\0' ? ":" : "", currVcfGenotype->details[0] != '\0' ? currVcfGenotype->details : "", i < arrayMax (currVcfEntry->genotypes) - 1 ? "\t" : ""); } puts (""); } } vcf_deInit (); return 0; }
int main (int argc, char *argv[]) { GfrEntry *currGE; int i,j,k,l, h,index; Stringa buffer,cmd,fnSequencesToAlign; FILE *fp; FILE *fp1; FILE *fp2; FILE *freads1; FILE *freads2; Array gfrEntries; BowtieQuery *currBQ,testBQ; BowtieEntry *currBE; Texta seqNames; int readSize1, readSize2, minReadSize; Array bowtieQueries; char transcriptNumber; int isHomologous,homologousCount; int count; int countRemoved; unsigned short int tooMany; BlatQuery *blQ; config *conf; if ((conf = confp_open(getenv("FUSIONSEQ_CONFPATH"))) == NULL) { die("%s:\tCannot find .fusionseqrc", argv[0]); return EXIT_FAILURE; } if ( (confp_get( conf, "BLAT_TWO_BIT_TO_FA")) == NULL) { die("%s:\tCannot find BLAT_TWO_BIT_TO_FA in the configuration file: %s", argv[0], getenv("FUSIONSEQ_CONFPATH") ); return EXIT_FAILURE; } if ( (confp_get( conf,"BLAT_DATA_DIR")) == NULL) { die("%s:\tCannot find BLAT_DATA_DIR in the configuration file: %sc", argv[0], getenv("FUSIONSEQ_CONFPATH") ); return EXIT_FAILURE; } if( confp_get( conf, "TMP_DIR")==NULL ) { die("%s:\tCannot find TMP_DIR in the configuration file: %s)", argv[0], getenv("FUSIONSEQ_CONFPATH") ); return EXIT_FAILURE; } if( confp_get( conf, "BLAT_GFSERVER")==NULL ) { die("%s:\tCannot find BLAT_GFSERVER in the configuration file: %s)", argv[0], getenv("FUSIONSEQ_CONFPATH") ); return EXIT_FAILURE; } if( confp_get( conf, "BLAT_GFCLIENT")==NULL ) { die("%s:\tCannot find BLAT_GFCLIENT in the configuration file: %s)", argv[0], getenv("FUSIONSEQ_CONFPATH") ); return EXIT_FAILURE; } if( confp_get( conf, "BLAT_GFSERVER_HOST")==NULL ) { die("%s:\tCannot find BLAT_GFSERVER_HOST in the configuration file: %s)", argv[0], getenv("FUSIONSEQ_CONFPATH") ); return EXIT_FAILURE; }if( confp_get( conf, "BLAT_GFSERVER_PORT")==NULL ) { die("%s:\tCannot find BLAT_GFSERVER_PORT in the configuration file: %s)", argv[0], getenv("FUSIONSEQ_CONFPATH") ); return EXIT_FAILURE; } if( confp_get( conf, "PSEUDOGENE_DIR")==NULL ) { die("%s:\tCannot find PSEUDOGENE_DIR in the configuration file: %s)", argv[0], getenv("FUSIONSEQ_CONFPATH") ); return EXIT_FAILURE; } if( confp_get( conf, "PSEUDOGENE_FILENAME")==NULL ) { die("%s:\tCannot find PSEUDOGENE_FILENAME in the configuration file: %s)", argv[0], getenv("FUSIONSEQ_CONFPATH") ); return EXIT_FAILURE; } cmd = stringCreate (100); // initializing the gfServers stringPrintf( cmd, "%s status %s %s &> /dev/null", confp_get( conf, "BLAT_GFSERVER"), confp_get( conf, "BLAT_GFSERVER_HOST"), confp_get( conf, "BLAT_GFSERVER_PORT") ); int ret = hlr_system( string(cmd), 1 ); if( ret != 0 ) { // not initialized stringPrintf( cmd , "%s -repMatch=100000 -tileSize=12 -canStop -log=%s/gfServer_genome.log start %s %s %s/%s &", confp_get( conf, "BLAT_GFSERVER"), confp_get(conf, "TMP_DIR"),confp_get( conf, "BLAT_GFSERVER_HOST"), confp_get( conf, "BLAT_GFSERVER_PORT"), confp_get(conf, "BLAT_DATA_DIR"), confp_get(conf, "BLAT_TWO_BIT_DATA_FILENAME")); hlr_system( string( cmd ), 0 ); long int startTime = time(0); stringPrintf( cmd , "%s status %s %s &2> /dev/null", confp_get( conf, "BLAT_GFSERVER"), confp_get( conf, "BLAT_GFSERVER_HOST"), confp_get( conf, "BLAT_GFSERVER_PORT")); while( hlr_system( string(cmd), 1) && (time(0)-startTime)<600 ) ; if( hlr_system( string(cmd), 1 ) != 0 ) { die("gfServer for %s/%s not initialized: %s %s %s", confp_get(conf, "BLAT_DATA_DIR"), confp_get(conf, "BLAT_TWO_BIT_DATA_FILENAME"), confp_get( conf, "BLAT_GFSERVER"), confp_get( conf, "BLAT_GFSERVER_HOST"), confp_get( conf, "BLAT_GFSERVER_PORT")); return EXIT_FAILURE; } } // end initialization gfr_init ("-"); gfrEntries = gfr_parse (); if (arrayMax (gfrEntries) == 0){ puts (gfr_writeHeader ()); gfr_deInit (); return 0; } seqNames = textCreate (10000); buffer = stringCreate (100); fnSequencesToAlign = stringCreate (100); count = 0; countRemoved = 0; stringPrintf( buffer, "%s/%s", confp_get( conf, "PSEUDOGENE_DIR"), confp_get( conf, "PSEUDOGENE_FILENAME") ); intervalFind_addIntervalsToSearchSpace (string(buffer),0); puts (gfr_writeHeader ()); for (i = 0; i < arrayMax (gfrEntries); i++) { currGE = arrp (gfrEntries,i,GfrEntry); homologousCount = 0; minReadSize=10000; // creating two fasta files with the two genes stringPrintf( cmd, "%s %s/%s -seq=%s -start=%d -end=%d %s/%s_transcript1.fa", confp_get(conf, "BLAT_TWO_BIT_TO_FA") , confp_get(conf, "BLAT_DATA_DIR"), confp_get(conf, "BLAT_TWO_BIT_DATA_FILENAME"), currGE->chromosomeTranscript1, currGE->startTranscript1, currGE->endTranscript1, confp_get(conf, "TMP_DIR"), currGE->id); hlr_system( string(cmd) , 0); stringPrintf( cmd, "%s %s/%s -seq=%s -start=%d -end=%d %s/%s_transcript2.fa", confp_get(conf, "BLAT_TWO_BIT_TO_FA"), confp_get(conf, "BLAT_DATA_DIR"), confp_get(conf, "BLAT_TWO_BIT_DATA_FILENAME"), currGE->chromosomeTranscript2, currGE->startTranscript2, currGE->endTranscript2, confp_get(conf, "TMP_DIR"), currGE->id); hlr_system( string(cmd) , 0); Stringa fa1 = stringCreate( 100 ); Stringa fa2 = stringCreate( 100 ); // creating the two fasta files with the reads stringPrintf( fa1, "%s/%s_reads1.fa", confp_get(conf, "TMP_DIR"), currGE->id); if (!(freads1 = fopen ( string(fa1) ,"w"))) { die ("Unable to open file: %s",string (fa1)); } // writing the reads of the first end into file for (l = 0; l < arrayMax (currGE->readsTranscript1); l++) { char* currRead1 = hlr_strdup( textItem (currGE->readsTranscript1,l)); // read1 readSize1 = strlen( currRead1 ); if( readSize1 == 0 ) die("Read size cannot be zero: read1[ %s ]", currRead1); if( readSize1 < minReadSize ) minReadSize = readSize1; fprintf( freads1, ">%d\n%s\n", l, currRead1 ); hlr_free( currRead1 ); } fclose( freads1 ); stringPrintf( fa2, "%s/%s_reads2.fa", confp_get(conf, "TMP_DIR"), currGE->id); if (!(freads2 = fopen ( string(fa2) ,"w"))) { die ("Unable to open file: %s",string (fa2)); } // writing the reads of the second end into file for (l = 0; l < arrayMax (currGE->readsTranscript2); l++) { char* currRead2 = hlr_strdup( textItem (currGE->readsTranscript2,l)); // read2 readSize2 = strlen( currRead2 ); if( readSize2 == 0 ) die("Read size cannot be zero: read2[ %s ]", currRead2); if( readSize2 < minReadSize ) minReadSize = readSize2; fprintf( freads2, ">%d\n%s\n", l, currRead2 ); hlr_free( currRead2 ); } fclose( freads2 ); // collapse the reads 2 ## requires the FASTX package stringPrintf( cmd, "%s -i %s/%s_reads2.fa -o %s/%s_reads2.collapsed.fa", confp_get(conf, "FASTX_COLLAPSER"), confp_get(conf, "TMP_DIR"), currGE->id, confp_get(conf, "TMP_DIR"), currGE->id ); hlr_system (string (cmd),0); //blat of reads2 against the first transcript stringPrintf( cmd, "%s -t=dna -out=psl -fine -tileSize=15 %s/%s_transcript1.fa %s/%s_reads2.collapsed.fa stdout",confp_get(conf, "BLAT_BLAT"), confp_get(conf, "TMP_DIR"), currGE->id, confp_get(conf, "TMP_DIR"), currGE->id ); // reading the results of blast from Pipe blatParser_initFromPipe( string(cmd) ); while( blQ = blatParser_nextQuery() ) { int nucleotideOverlap = getNucleotideOverlap ( blQ ); if ( nucleotideOverlap > ( ((double)readSize2)* atof(confp_get(conf,"MAX_OVERLAP_ALLOWED"))) ) { char* value = strchr(blQ->qName,'-'); homologousCount+=atoi(value+1); } } blatParser_deInit(); // collapse the reads 1 ## requires the FASTX package on the path stringPrintf( cmd, "%s -i %s/%s_reads1.fa -o %s/%s_reads1.collapsed.fa", confp_get(conf, "FASTX_COLLAPSER"), confp_get(conf, "TMP_DIR"), currGE->id, confp_get(conf, "TMP_DIR"), currGE->id ); hlr_system (string (cmd),0); //blat of reads1 against the second transcript stringPrintf( cmd, "%s -t=dna -out=psl -fine -tileSize=15 %s/%s_transcript2.fa %s/%s_reads1.collapsed.fa stdout",confp_get(conf, "BLAT_BLAT"), confp_get(conf, "TMP_DIR"), currGE->id, confp_get(conf, "TMP_DIR"), currGE->id ); blatParser_initFromPipe( string(cmd) ); while( blQ = blatParser_nextQuery() ) { int nucleotideOverlap = getNucleotideOverlap ( blQ ); if ( nucleotideOverlap > ( ((double)readSize1)* atof(confp_get(conf,"MAX_OVERLAP_ALLOWED"))) ) { char* value = strchr(blQ->qName,'-'); homologousCount+=atoi(value+1); } } blatParser_deInit(); stringPrintf (cmd,"cd %s;rm -rf %s_reads?.fa %s_reads?.collapsed.fa %s_transcript?.fa", confp_get(conf, "TMP_DIR"), currGE->id,currGE->id,currGE->id); hlr_system( string(cmd) , 0); if (((double)homologousCount / (double)arrayMax(currGE->readsTranscript1)) <= atof(confp_get(conf, "MAX_FRACTION_HOMOLOGOUS")) ) { homologousCount = 0; // there is no homology between the two genes, but what about the rest of the genome writeFasta( currGE, &minReadSize, confp_get(conf, "TMP_DIR") ); stringPrintf(cmd, "cd %s; %s %s %s / -t=dna -q=dna -minScore=%d -out=psl %s_reads.fa %s.smallhomology.psl &>/dev/null", confp_get(conf, "TMP_DIR"), confp_get( conf, "BLAT_GFCLIENT"), confp_get( conf, "BLAT_GFSERVER_HOST"), confp_get( conf, "BLAT_GFSERVER_PORT"), minReadSize - (int)(0.1 * minReadSize) > 20 ? minReadSize - (int) (0.1 * minReadSize) : 20 , currGE->id, currGE->id); int attempts=0; ret = hlr_system( string(cmd), 1 ); while( hlr_system( string(cmd), 1 ) && attempts<5000 ) attempts++; if( attempts == 5000 ) { die("Cannot map the reads %s", string( cmd )); return EXIT_FAILURE; } // reading the results of blast from File stringPrintf(cmd, "%s/%s.smallhomology.psl", confp_get( conf, "TMP_DIR"), currGE->id); blatParser_initFromFile( string(cmd) ); tooMany = 1; while( blQ = blatParser_nextQuery() ) { tooMany = 0; checkPseudogeneOverlap( blQ ); if( arrayMax( blQ->entries ) > 1 ) { homologousCount+= arrayMax( blQ->entries ) - 1; char* value = strchr( blQ->qName,'/' ); if( value ) *value = '\0'; else die("Not a valid index in the blat query name:\t%s", blQ->qName ); int indexOfInter = atoi( blQ->qName ); // the following three lines should removed the read if writing the GFR entry GfrInterRead *currGIR = arrp( currGE->interReads, indexOfInter, GfrInterRead ); currGIR->flag = 1; } } blatParser_deInit(); if ( tooMany == 1 || ( ( (double) homologousCount / (double) ( arrayMax(currGE->readsTranscript1) + arrayMax(currGE->readsTranscript2) ) ) > atof(confp_get(conf, "MAX_FRACTION_HOMOLOGOUS")) ) ) { countRemoved++; stringPrintf (cmd,"cd %s; rm -rf %s_reads*.fa %s_reads?.collapsed.fa %s_transcript?.fa %s.smallhomology.psl", confp_get(conf, "TMP_DIR"), currGE->id,currGE->id,currGE->id,currGE->id); hlr_system( string(cmd), 1 ); continue; } // writing the gfrEntry, if everthing else didn't stop if( homologousCount > 0 ) updateStats( currGE ); puts (gfr_writeGfrEntry (currGE)); count++; // removing temporary files stringPrintf (cmd,"cd %s;rm -rf %s_reads*.fa %s_reads?.collapsed.fa %s_transcript?.fa %s.smallhomology.psl", confp_get(conf, "TMP_DIR"), currGE->id,currGE->id,currGE->id,currGE->id); hlr_system( string(cmd) , 1); } else { countRemoved++; } } gfr_deInit (); stringDestroy (fnSequencesToAlign); stringDestroy (cmd); stringDestroy (buffer); warn ("%s_numRemoved: %d",argv[0],countRemoved); warn ("%s_numGfrEntries: %d",argv[0],count); confp_close(conf); return EXIT_SUCCESS; }
void incl_getExonHlightFile (FILE *fp, Array regions, char *sdata_dir) { LineStream src; FILE *out; char *line; Texta entry; int i, astart, aend; Stringa buffer = stringCreate (50); stringPrintf (buffer, "%s/tmp/exons.hlight_s.txt", sdata_dir); if (!(out = fopen (string (buffer), "w"))) { fprintf (stderr, "Cannot open exons.hlight_s.txt\n"); return; } SRegion_t *tmp; tmp = arrayp (regions, 0, SRegion_t); if (tmp->chromosome == 0) { fprintf (fp, "file = %s/exons.hlight.txt\n", sdata_dir); } else { for (i = 0; i < arrayMax (regions); i++) { tmp = arrayp (regions, i, SRegion_t); if (tmp->chromosome == 23) { stringPrintf (buffer, "%s/X/exons.hlight.txt", sdata_dir); } else if (tmp->chromosome == 24) { stringPrintf (buffer, "%s/Y/exons.hlight.txt", sdata_dir); } else { stringPrintf (buffer, "%s/%i/exons.hlight.txt", sdata_dir, tmp->chromosome); } if ((src = ls_createFromFile (string (buffer))) == NULL) { fprintf (stderr, "Cannot open exons.hlight.txt\n"); return; } while ((line = ls_nextLine (src)) != NULL) { entry = textFieldtokP (line, " "); astart = atoi (textItem (entry, 1)); aend = atoi (textItem (entry, 2)); if ((astart >= tmp->start && astart <= tmp->end) || (aend >= tmp->start && aend <= tmp->end)) { fprintf (out, "%s\n", line); } textDestroy (entry); } } fprintf (fp, "file = %s/tmp/exons.hlight_s.txt\n", sdata_dir); } stringDestroy (buffer); ls_destroy (src); fclose (out); }
SEXP c_read_biokit_exprs (SEXP filename) { LineStream ls; char* line; const int MAND_NCOL=7; // the first column is the row name, and column 2-7 are mandatory int add_ncol=0; Texta it; Texta rnames=textCreate(128); Array mrpkms=arrayCreate(128, double); Array mreads=arrayCreate(128, int); Array srpkms=arrayCreate(128, double); Array sreads=arrayCreate(128, int); Array mprop=arrayCreate(128, double); Array allmap = arrayCreate(128, int); Array annos=arrayCreate(128, Texta); Texta anno=NULL; // must have a NULL assigned; otherwise textCreateClear leads to memory error Stringa str=stringCreate(8); SEXP R_rnames, R_mrpkms, R_mreads, R_srpkms, R_sreads, R_mprop, R_allmap, R_res; SEXP R_colnames, R_class; int nprot=0; int i=0; int j=0; int nrow=0; const char* fn=CHAR(STRING_ELT(filename, 0)); ls = ls_createFromFile(strdup(fn)); ls_nextLine(ls); // skip the first header line while(line = ls_nextLine(ls)) { it = textFieldtokP(line, "\t"); if(arrayMax(it)<MAND_NCOL) error("Input file must contain no less than %d columns", MAND_NCOL); textAdd(rnames, textItem(it, 0)); array(mrpkms, arrayMax(mrpkms), double)=atof(textItem(it, 1)); array(mreads, arrayMax(mreads), int)=atoi(textItem(it, 2)); array(srpkms, arrayMax(srpkms), double)=atof(textItem(it, 3)); array(sreads, arrayMax(sreads), int)=atoi(textItem(it, 4)); array(mprop, arrayMax(mprop), double)=atof(textItem(it, 5)); array(allmap, arrayMax(allmap), int)=atoi(textItem(it, 6)); add_ncol = max(arrayMax(it)-MAND_NCOL, add_ncol); textCreateClear(anno, arrayMax(it)-MAND_NCOL); for(i=MAND_NCOL; i<arrayMax(it); ++i) { textAdd(anno, textItem(it, i)); } array(annos, arrayMax(annos), Texta)=textClone(anno); nrow++; } R_rnames=PROTECT(allocVector(STRSXP, nrow)); nprot++; R_mrpkms=PROTECT(allocVector(REALSXP, nrow)); nprot++; R_mreads=PROTECT(allocVector(INTSXP, nrow)); nprot++; R_srpkms=PROTECT(allocVector(REALSXP, nrow)); nprot++; R_sreads=PROTECT(allocVector(INTSXP, nrow)); nprot++; R_mprop=PROTECT(allocVector(REALSXP, nrow)); nprot++; R_allmap=PROTECT(allocVector(INTSXP, nrow)); nprot++; for(i=0; i<nrow; ++i) { SET_STRING_ELT(R_rnames, i, mkChar(textItem(rnames, i))); REAL(R_mrpkms)[i]=arru(mrpkms, i, double); INTEGER(R_mreads)[i]=arru(mreads, i, int); REAL(R_srpkms)[i]=arru(srpkms, i, double); INTEGER(R_sreads)[i]=arru(sreads, i, int); REAL(R_mprop)[i]=arru(mprop, i, double); INTEGER(R_allmap)[i]=arru(allmap, i, int); } R_res=PROTECT(allocVector(VECSXP, MAND_NCOL+add_ncol-1)); nprot++; SET_VECTOR_ELT(R_res, 0, R_mrpkms); SET_VECTOR_ELT(R_res, 1, R_mreads); SET_VECTOR_ELT(R_res, 2, R_srpkms); SET_VECTOR_ELT(R_res, 3, R_sreads); SET_VECTOR_ELT(R_res, 4, R_mprop); SET_VECTOR_ELT(R_res, 5, R_allmap); for(i=0; i<add_ncol; ++i) { SEXP R_anno=NULL; R_anno=PROTECT(allocVector(STRSXP, nrow)); for(j=0; j<nrow; ++j) { anno=array(annos, j, Texta); if(arrayMax(anno)>i) { SET_STRING_ELT(R_anno, j, mkChar(textItem(anno, i))); } else { SET_STRING_ELT(R_anno, j, R_NaString); } } SET_VECTOR_ELT(R_res, i+MAND_NCOL-1, R_anno); // -1 because the first column is row name UNPROTECT(1); } PROTECT(R_colnames=allocVector(STRSXP, MAND_NCOL+add_ncol-1)); nprot++; PROTECT(R_class=allocVector(STRSXP, 1)); nprot++; SET_STRING_ELT(R_colnames, 0, mkChar("RPKM_MultiMap")); SET_STRING_ELT(R_colnames, 1, mkChar("ReadCount_MultiMap")); SET_STRING_ELT(R_colnames, 2, mkChar("RPKM_UniqMap")); SET_STRING_ELT(R_colnames, 3, mkChar("ReadCount_UniqMap")); SET_STRING_ELT(R_colnames, 4, mkChar("MultiProp")); SET_STRING_ELT(R_colnames, 5, mkChar("AllMappingReads")); for(i=0; i<add_ncol; ++i) { stringPrintf(str, "Annotation%d", i+1); SET_STRING_ELT(R_colnames, i+MAND_NCOL-1, mkChar(string(str))); } SET_STRING_ELT(R_class, 0, mkChar("data.frame")); setAttrib(R_res, install("names"), R_colnames); setAttrib(R_res, install("row.names"), R_rnames); setAttrib(R_res, install("class"), R_class); for(i=0; i<nrow; ++i) { textDestroy(array(annos, i, Texta)); } arrayDestroy(annos); arrayDestroy(rnames); arrayDestroy(mrpkms); arrayDestroy(mreads); arrayDestroy(srpkms); arrayDestroy(sreads); arrayDestroy(mprop); arrayDestroy(allmap); stringDestroy(str); ls_destroy(ls); UNPROTECT(nprot); return(R_res); }
int generateSamEntry ( Texta tokens, SamEntry *currSamE, int* hasSeqs, int* hasQual) { int j; currSamE->qname = strdup (textItem (tokens, 0)); currSamE->flags = atoi (textItem (tokens, 1)); currSamE->rname = strdup (textItem (tokens, 2)); currSamE->pos = atoi (textItem (tokens, 3)); currSamE->mapq = atoi (textItem (tokens, 4)); currSamE->cigar = strdup (textItem (tokens, 5)); currSamE->mrnm = strdup (textItem (tokens, 6)); currSamE->mpos = atoi (textItem (tokens, 7)); currSamE->isize = atoi (textItem (tokens, 8)); currSamE->seq = NULL; currSamE->qual = NULL; currSamE->tags = NULL; // Skip if unmapped or fails platform/vendor checks if (currSamE->flags & S_QUERY_UNMAPPED || currSamE->flags & S_MATE_UNMAPPED || currSamE->flags & S_FAILS_CHECKS) return 0; // Get tokens if (arrayMax (tokens) > 11) { Stringa tags = stringCreate (10); for (j = 11; j < arrayMax (tokens); j++) { if (j > 11) stringAppendf (tags, "\t"); stringAppendf (tags, "%s", textItem (tokens, j)); } currSamE->tags = strdup (string(tags)); stringDestroy (tags); } if (strcmp (textItem (tokens, 9), "*") != 0) { *hasSeqs = 1; currSamE->seq = strdup (textItem (tokens, 9)); } if (strcmp (textItem (tokens, 10), "*") != 0) { *hasQual = 1; currSamE->qual = strdup (textItem (tokens, 10)); } return 1; }
int main (int argc, char *argv[]) { Array intervals; Interval *currInterval; SubInterval *currSubInterval; int h,i,j; Array seqs; Seq *currSeq,testSeq; int index; Stringa buffer; Array geneTranscriptEntries; Texta geneTranscriptIds; Array alterations; Alteration *currAlteration,*nextAlteration; char *proteinSequenceBeforeIndel; char *proteinSequenceAfterIndel; int numDisabledTranscripts; Stringa disabledTranscripts; int seqLength,refLength,altLength; char *sequenceBeforeIndel = NULL; int overlapMode; int numOverlaps; int sizeIndel,indelOffset; int overlap; Array coordinates; VcfEntry *currVcfEntry; VcfGenotype *currVcfGenotype; int position; Texta alternateAlleles; int flag1,flag2; if (argc != 3) { usage ("%s <annotation.interval> <annotation.fa>",argv[0]); } intervalFind_addIntervalsToSearchSpace (argv[1],0); geneTranscriptEntries = util_getGeneTranscriptEntries (intervalFind_getAllIntervals ()); seq_init (); fasta_initFromFile (argv[2]); seqs = fasta_readAllSequences (0); fasta_deInit (); arraySort (seqs,(ARRAYORDERF)util_sortSequencesByName); buffer = stringCreate (100); disabledTranscripts = stringCreate (100); alterations = arrayCreate (100,Alteration); vcf_init ("-"); stringPrintf (buffer,"##INFO=<ID=VA,Number=.,Type=String,Description=\"Variant Annotation, %s\">",argv[1]); vcf_addComment (string (buffer)); puts (vcf_writeMetaData ()); puts (vcf_writeColumnHeaders ()); while (currVcfEntry = vcf_nextEntry ()) { if (vcf_isInvalidEntry (currVcfEntry)) { continue; } flag1 = 0; flag2 = 0; position = currVcfEntry->position - 1; // make zero-based alternateAlleles = vcf_getAlternateAlleles (currVcfEntry); for (h = 0; h < arrayMax (alternateAlleles); h++) { refLength = strlen (currVcfEntry->referenceAllele); altLength = strlen (textItem (alternateAlleles,h)); sizeIndel = abs (refLength - altLength); indelOffset = MAX (refLength,altLength) - 1; util_clearAlterations (alterations); intervals = intervalFind_getOverlappingIntervals (currVcfEntry->chromosome,position,position + indelOffset); for (i = 0; i < arrayMax (intervals); i++) { currInterval = arru (intervals,i,Interval*); overlapMode = OVERLAP_NONE; numOverlaps = 0; for (j = 0; j < arrayMax (currInterval->subIntervals); j++) { currSubInterval = arrp (currInterval->subIntervals,j,SubInterval); overlap = rangeIntersection (position,position + indelOffset,currSubInterval->start,currSubInterval->end); if (currSubInterval->start <= position && (position + indelOffset) < currSubInterval->end) { overlapMode = OVERLAP_FULLY_CONTAINED; numOverlaps++; } else if (j == 0 && overlap > 0 && position < currSubInterval->start) { overlapMode = OVERLAP_START; numOverlaps++; } else if (j == (arrayMax (currInterval->subIntervals) - 1) && overlap > 0 && (position + indelOffset) >= currSubInterval->end) { overlapMode = OVERLAP_END; numOverlaps++; } else if (overlap > 0 && overlap <= indelOffset) { overlapMode = OVERLAP_SPLICE; numOverlaps++; } } if (overlapMode == OVERLAP_NONE) { continue; } currAlteration = arrayp (alterations,arrayMax (alterations),Alteration); if (numOverlaps > 1) { util_addAlteration (currAlteration,currInterval->name,"multiExonHit",currInterval,position,0); continue; } else if (numOverlaps == 1 && overlapMode == OVERLAP_SPLICE) { util_addAlteration (currAlteration,currInterval->name,"spliceOverlap",currInterval,position,0); continue; } else if (numOverlaps == 1 && overlapMode == OVERLAP_START) { util_addAlteration (currAlteration,currInterval->name,"startOverlap",currInterval,position,0); continue; } else if (numOverlaps == 1 && overlapMode == OVERLAP_END) { util_addAlteration (currAlteration,currInterval->name,"endOverlap",currInterval,position,0); continue; } else if (numOverlaps == 1 && overlapMode == OVERLAP_FULLY_CONTAINED && altLength > refLength) { if ((sizeIndel % 3) == 0) { util_addAlteration (currAlteration,currInterval->name,"insertionNFS",currInterval,position,0); } else { util_addAlteration (currAlteration,currInterval->name,"insertionFS",currInterval,position,0); } } else if (numOverlaps == 1 && overlapMode == OVERLAP_FULLY_CONTAINED && altLength < refLength) { if ((sizeIndel % 3) == 0) { util_addAlteration (currAlteration,currInterval->name,"deletionNFS",currInterval,position,0); } else { util_addAlteration (currAlteration,currInterval->name,"deletionFS",currInterval,position,0); } } else if (numOverlaps == 1 && overlapMode == OVERLAP_FULLY_CONTAINED && altLength == refLength) { util_addAlteration (currAlteration,currInterval->name,"substitution",currInterval,position,0); } else { die ("Unexpected type: %d %s %s %s", currVcfEntry->position,currVcfEntry->chromosome, currVcfEntry->referenceAllele,currVcfEntry->alternateAllele); } if ((sizeIndel % 3) != 0 && altLength != refLength) { continue; } // Only run the remaining block of code if the indel is fully contained (insertion or deletion) AND does not cause a frameshift OR // if it is a substitution that is fully contained in the coding sequence stringPrintf (buffer,"%s|%s|%c|",currInterval->name,currInterval->chromosome,currInterval->strand); for (j = 0; j < arrayMax (currInterval->subIntervals); j++) { currSubInterval = arrp (currInterval->subIntervals,j,SubInterval); stringAppendf (buffer,"%d|%d%s",currSubInterval->start,currSubInterval->end,j < arrayMax (currInterval->subIntervals) - 1 ? "|" : ""); } testSeq.name = hlr_strdup (string (buffer)); if (!arrayFind (seqs,&testSeq,&index,(ARRAYORDERF)util_sortSequencesByName)) { die ("Expected to find %s in seqs",string (buffer)); } hlr_free (testSeq.name); currSeq = arrp (seqs,index,Seq); strReplace (&sequenceBeforeIndel,currSeq->sequence); seqLength = strlen (sequenceBeforeIndel); coordinates = util_getCoordinates (currInterval); // arraySort (coordinates,(ARRAYORDERF)util_sortCoordinatesByChromosomeAndTranscriptPosition); Array is already sorted by definition j = 0; stringClear (buffer); while (j < seqLength) { if (util_getGenomicCoordinate (coordinates,j,currVcfEntry->chromosome) == position) { if (altLength > refLength) { stringCat (buffer,textItem (alternateAlleles,h)); j++; continue; } else if (altLength < refLength) { stringCatChar (buffer,sequenceBeforeIndel[j]); j = j + refLength - altLength + 1; continue; } else { stringCat (buffer,textItem (alternateAlleles,h)); j = j + altLength; continue; } } stringCatChar (buffer,sequenceBeforeIndel[j]); j++; } util_destroyCoordinates (coordinates); proteinSequenceBeforeIndel = hlr_strdup (util_translate (currInterval,sequenceBeforeIndel)); proteinSequenceAfterIndel = hlr_strdup (util_translate (currInterval,string (buffer))); addSubstitution (currAlteration,proteinSequenceBeforeIndel,proteinSequenceAfterIndel,indelOffset); hlr_free (proteinSequenceBeforeIndel); hlr_free (proteinSequenceAfterIndel); } if (arrayMax (alterations) == 0) { continue; } arraySort (alterations,(ARRAYORDERF)util_sortAlterationsByGeneIdAndType); stringClear (buffer); i = 0; while (i < arrayMax (alterations)) { currAlteration = arrp (alterations,i,Alteration); stringAppendf (buffer,"%s%d:%s:%s:%c:%s",stringLen (buffer) == 0 ? "" : ",",h + 1,currAlteration->geneName,currAlteration->geneId,currAlteration->strand,currAlteration->type); stringClear (disabledTranscripts); if (currAlteration->substitution[0] != '\0') { stringAppendf (disabledTranscripts,"%s:%s:%d_%d_%s",currAlteration->transcriptName,currAlteration->transcriptId,currAlteration->transcriptLength,currAlteration->relativePosition,currAlteration->substitution); } else if (strEqual (currAlteration->type,"multiExonHit") || strEqual (currAlteration->type,"spliceOverlap") || strEqual (currAlteration->type,"startOverlap") || strEqual (currAlteration->type,"endOverlap")) { stringAppendf (disabledTranscripts,"%s:%s:%d",currAlteration->transcriptName,currAlteration->transcriptId,currAlteration->transcriptLength); } else { stringAppendf (disabledTranscripts,"%s:%s:%d_%d",currAlteration->transcriptName,currAlteration->transcriptId,currAlteration->transcriptLength,currAlteration->relativePosition); } numDisabledTranscripts = 1; j = i + 1; while (j < arrayMax (alterations)) { nextAlteration = arrp (alterations,j,Alteration); if (strEqual (currAlteration->geneId,nextAlteration->geneId) && strEqual (currAlteration->type,nextAlteration->type)) { if (nextAlteration->substitution[0] != '\0') { stringAppendf (disabledTranscripts,":%s:%s:%d_%d_%s",nextAlteration->transcriptName,nextAlteration->transcriptId,nextAlteration->transcriptLength,nextAlteration->relativePosition,nextAlteration->substitution); } else if (strEqual (nextAlteration->type,"multiExonHit") || strEqual (nextAlteration->type,"spliceOverlap") || strEqual (nextAlteration->type,"startOverlap") || strEqual (nextAlteration->type,"endOverlap")) { stringAppendf (disabledTranscripts,":%s:%s:%d",nextAlteration->transcriptName,nextAlteration->transcriptId,nextAlteration->transcriptLength); } else { stringAppendf (disabledTranscripts,":%s:%s:%d_%d",nextAlteration->transcriptName,nextAlteration->transcriptId,nextAlteration->transcriptLength,nextAlteration->relativePosition); } numDisabledTranscripts++; } else { break; } j++; } i = j; geneTranscriptIds = util_getTranscriptIdsForGeneId (geneTranscriptEntries,currAlteration->geneId); stringAppendf (buffer,":%d/%d:%s",numDisabledTranscripts,arrayMax (geneTranscriptIds),string (disabledTranscripts)); } if (flag1 == 0) { printf ("%s\t%d\t%s\t%s\t%s\t%s\t%s\t%s;VA=", currVcfEntry->chromosome,currVcfEntry->position,currVcfEntry->id, currVcfEntry->referenceAllele,currVcfEntry->alternateAllele, currVcfEntry->quality,currVcfEntry->filter,currVcfEntry->info); flag1 = 1; } printf ("%s%s",flag2 == 1 ? "," : "",string (buffer)); flag2 = 1; } if (flag1 == 1) { for (i = 0; i < arrayMax (currVcfEntry->genotypes); i++) { currVcfGenotype = arrp (currVcfEntry->genotypes,i,VcfGenotype); if (i == 0) { printf ("\t%s\t",currVcfEntry->genotypeFormat); } printf ("%s%s%s%s",currVcfGenotype->genotype, currVcfGenotype->details[0] != '\0' ? ":" : "", currVcfGenotype->details[0] != '\0' ? currVcfGenotype->details : "", i < arrayMax (currVcfEntry->genotypes) - 1 ? "\t" : ""); } puts (""); } } vcf_deInit (); return 0; }