@@ -164,6 +164,8 @@ bool ballgown=false;
164164// no more reads will be considered for a bundle if the local coverage exceeds this value
165165// (each exon is checked for this)
166166
167+ bool forceBAM = false ; // useful for stdin (piping alignments into StringTie)
168+
167169bool mergeMode = false ; // --merge option
168170bool keepTempFiles = false ; // --keeptmp
169171
@@ -232,8 +234,6 @@ void writeUnbundledGuides(GVec<GRefData>& refdata, FILE* fout, FILE* gout=NULL);
232234
233235#ifndef NOTHREADS
234236
235- bool waitForThreads (); // wait for at least 1 worker thread to enter "ready" state
236-
237237bool noThreadsWaiting ();
238238
239239void workerThread (GThreadData& td); // Thread function
@@ -253,7 +253,7 @@ int main(int argc, char * const argv[]) {
253253 // == Process arguments.
254254 GArgs args (argc, argv,
255255 // "debug;help;fast;xhvntj:D:G:C:l:m:o:a:j:c:f:p:g:");
256- " debug;help;version;keeptmp;merge;exclude=zZSEihvteux:n:j:s:D:G:C:l:m:o:a:j:c:f:p:g:P:M:Bb:A:F:T:" );
256+ " debug;help;version;keeptmp;bam; merge;exclude=zZSEihvteux:n:j:s:D:G:C:l:m:o:a:j:c:f:p:g:P:M:Bb:A:F:T:" );
257257 args.printError (USAGE, true );
258258
259259 processOptions (args);
@@ -361,12 +361,9 @@ const char* ERR_BAM_SORT="\nError: the input alignment file is not sorted!\n";
361361 gseqNames=GffObj::names; // might have been populated already by gff data
362362 gffnames_ref (gseqNames); // initialize the names collection if not guided
363363
364- // GBamReader bamreader(bamfname.chars());
365-
366364
367365 GHash<int > hashread; // read_name:pos:hit_index => readlist index
368- // GHash<int> bgeneids(false); //guide gene IDs/names in the bundle
369- // set of annotation transcript for the current locus
366+
370367 GList<GffObj>* guides=NULL ; // list of transcripts on a specific chromosome
371368
372369 int currentstart=0 , currentend=0 ;
@@ -434,6 +431,11 @@ if (tstackSize<DEF_TSTACK_SIZE) defStackSize=DEF_TSTACK_SIZE;
434431 // delete brec;
435432 if ((brec=bamreader.next ())!=NULL ) {
436433 if (brec->isUnmapped ()) continue ;
434+ if (brec->start <1 || brec->mapped_len <10 ) {
435+ if (verbose) GMessage (" Warning: invalid mapping found for read %s (position=%d, mapped length=%d)\n " ,
436+ brec->name (), brec->start , brec->mapped_len );
437+ continue ;
438+ }
437439
438440 refseqName=brec->refName ();
439441 xstrand=brec->spliceStrand ();
@@ -563,8 +565,10 @@ if (tstackSize<DEF_TSTACK_SIZE) defStackSize=DEF_TSTACK_SIZE;
563565#ifndef NOTHREADS
564566 GLockGuard<GFastMutex> lock (logMutex);
565567#endif
566- printTime (stderr);
567- if (Num_Fragments) GMessage (" %g aligned fragments found.\n " , Num_Fragments);
568+ if (Num_Fragments) {
569+ printTime (stderr);
570+ GMessage (" %g aligned fragments found.\n " , Num_Fragments);
571+ }
568572 // GMessage(" Done reading alignments.\n");
569573 }
570574 noMoreBundles ();
@@ -702,13 +706,13 @@ if (tstackSize<DEF_TSTACK_SIZE) defStackSize=DEF_TSTACK_SIZE;
702706 fclose (f_out);
703707 if (c_out && c_out!=stdout) fclose (c_out);
704708
705- if (verbose)
706- GMessage (" Total number of records without the XS tag: %d\n " ,no_xs);
709+ if (verbose && no_xs> 0 )
710+ GMessage (" Number spliced alignments missing the XS tag (skipped) : %d\n " ,no_xs);
707711
708712if (!mergeMode) {
709713 if (verbose) {
710- GMessage (" Total count of aligned fragments: %g\n " ,Num_Fragments);
711- GMessage (" Fragment coverage length:%g\n " ,Frag_Len/Num_Fragments);
714+ GMessage (" Total count of aligned fragments: %g\n " , Num_Fragments);
715+ GMessage (" Fragment coverage length: %g\n " , Frag_Len/Num_Fragments);
712716 }
713717
714718 f_out=stdout;
@@ -835,6 +839,7 @@ void processOptions(GArgs& args) {
835839 exit (0 );
836840 }
837841 debugMode=(args.getOpt (" debug" )!=NULL || args.getOpt (' D' )!=NULL );
842+ forceBAM=(args.getOpt (" bam" )!=NULL ); // assume the stdin stream is BAM instead of text SAM
838843 mergeMode=(args.getOpt (" merge" )!=NULL );
839844 keepTempFiles=(args.getOpt (" keeptmp" )!=NULL );
840845 fast=!(args.getOpt (' Z' )!=NULL );
@@ -1165,9 +1170,6 @@ void processBundle(BundleData* bundle) {
11651170 GLockGuard<GFastMutex> lock (logMutex);
11661171 #endif
11671172 printTime (stderr);
1168- /* GMessage(">bundle %s:%d-%d(%d) (%djs, %d guides) loaded, begins processing...\n",
1169- bundle->refseq.chars(), bundle->start, bundle->end, bundle->numreads,
1170- bundle->junction.Count(), bundle->keepguides.Count());*/
11711173 GMessage (" >bundle %s:%d-%d(%lu) (%d guides) loaded, begins processing...\n " ,
11721174 bundle->refseq .chars (), bundle->start , bundle->end , bundle->numreads ,
11731175 bundle->keepguides .Count ());
@@ -1208,7 +1210,6 @@ void processBundle(BundleData* bundle) {
12081210
12091211 }
12101212#endif
1211- // int ngenes=infer_transcripts(bundle, fast | bundle->covSaturated);
12121213 int ngenes=infer_transcripts (bundle);
12131214
12141215 if (ballgown && bundle->rc_data ) {
@@ -1235,7 +1236,6 @@ void processBundle(BundleData* bundle) {
12351236 #ifndef NOTHREADS
12361237 GLockGuard<GFastMutex> lock (logMutex);
12371238 #endif
1238- printTime (stderr);
12391239 /*
12401240 SumReads+=bundle->sumreads;
12411241 SumFrag+=bundle->sumfrag;
@@ -1247,6 +1247,7 @@ void processBundle(BundleData* bundle) {
12471247 fprintf(stderr,"Number of fragments in bundle: %g with length %g\n",bundle->num_fragments,bundle->frag_len);
12481248 fprintf(stderr,"Number of fragments in bundle: %g with sum %g\n",bundle->num_fragments,bundle->frag_len);
12491249 */
1250+ printTime (stderr);
12501251 GMessage (" ^bundle %s:%d-%d(%d) done (%d processed potential transcripts).\n " ,bundle->refseq .chars (),
12511252 bundle->start , bundle->end , bundle->readlist .Count (), bundle->pred .Count ());
12521253 #ifdef GMEMTRACE
@@ -1272,22 +1273,6 @@ bool noThreadsWaiting() {
12721273 return (v<1 );
12731274}
12741275
1275- bool waitForThreads () {
1276- bool noneWaiting=true ;
1277- DBGPRINT (" ##> waiting for a thread to become available..\n " );
1278- while (noneWaiting) {
1279- waitMutex.lock ();
1280- noneWaiting=(threadsWaiting<1 );
1281- waitMutex.unlock ();
1282- if (noneWaiting) {
1283- DBGPRINT (" ##>all threads busy, sleep_for 2ms\n " );
1284- this_thread::sleep_for (chrono::milliseconds (2 ));
1285- }
1286- }
1287- DBGPRINT (" ##> there are workers ready now.\n " );
1288- return (!noneWaiting);
1289- }
1290-
12911276void workerThread (GThreadData& td) {
12921277 GPVec<BundleData>* bundleQueue = (GPVec<BundleData>*)td.udata ;
12931278 // wait for a ready bundle in the queue, until there is no hope for incoming bundles
0 commit comments