ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/tophat_cpp/reads.cpp
(Generate patch)
# Line 173 | Line 173
173  
174   bool next_fastx_read(FLineReader& fr, Read& read, ReadFormat reads_format,
175                          FLineReader* frq) {
176 +  /*
177    if (fr.pushed_read)
178      {
179        read = fr.last_read;
180        fr.pushed_read = false;
181        return true;
182      }
183 <  
183 >  */
184    read.clear();
185    char* buf=NULL;
186    while ((buf=fr.nextLine())!=NULL) {
# Line 262 | Line 263
263             }
264      }
265  
266 <  fr.last_read = read;  
266 >  //fr.last_read = read;
267    return !(read.seq.empty());
268   }
269  
# Line 594 | Line 595
595   }
596  
597  
598 + void bam2Read(const bam1_t *b, Read& rd) {
599 +
600 +  GBamRecord bamrec(b);
601 +  rd.clear();
602 +  rd.seq=bam1_qname(b);
603 +  rd.name=name;
604 + }
605 +
606 +
607   bool ReadStream::next_read(Read& r, ReadFormat read_format) {
608 <  FLineReader fr(fstream.file);
599 <  while (read_pq.size()<500000 && !r_eof) {
608 >  while (read_pq.size()<ReadBufSize && !r_eof) {
609      //keep the queue topped off
610      Read rf;
611 <    if (!next_fastx_read(fr, rf, read_format)) {
611 >    if (!next_fastx_read(*flseqs, rf, read_format, flquals)) {
612          r_eof=true;
613          break;
614          }
# Line 616 | Line 625
625    return true;
626   }
627  
628 + bool ReadStream::get_direct(Read& r, ReadFormat read_format) {
629 +   r.clear();
630 +   if (fstream.is_bam) {
631 +     if (samread(fstream.bam_file, b) >= 0) {
632 +
633 +       return true;
634 +       }
635 +     return false;
636 +     }
637 +   if (!next_fastx_read(*flseqs, r, read_format, flquals)) {
638 +        r_eof=true;
639 +        return false;
640 +        }
641 +  return true;
642 + }
643 +
644 +
645 +
646   // reads must ALWAYS requested in increasing order of their ID
647   bool ReadStream::getRead(uint64_t r_id,
648                           Read& read,
# Line 669 | Line 696
696      } //while reads
697    return found;
698   }
672
673
674 bool get_read_from_stream(uint64_t insert_id,
675                          FLineReader& fr,
676                          ReadFormat reads_format,
677                          bool strip_slash,
678                          Read& read,
679                          FILE* um_out,
680                          bool um_write_found)
681 {
682  bool found=false;
683  while(!found && !fr.isEof())
684    {
685    read.clear();
686
687      // Get the next read from the file
688    if (!next_fastx_read(fr, read, reads_format))
689        break;
690    if (strip_slash)
691      {
692        string::size_type slash = read.name.rfind("/");
693        if (slash != string::npos)
694          read.name.resize(slash);
695      }
696    uint64_t id = (uint64_t)atoi(read.name.c_str());
697    if (id == insert_id)
698      {
699        found=true;
700      }
701    else if (id > insert_id)
702      {
703          fr.pushBack_read();
704          break;
705      }
706
707    if (um_out && ((um_write_found && found) ||
708                   (!um_write_found && !found))) {
709     //write unmapped reads
710      fprintf(um_out, "@%s\n%s\n+\n%s\n", read.alt_name.c_str(),
711                              read.seq.c_str(), read.qual.c_str());
712      }
713    //rt.get_id(read.name, ref_str);
714    } //while reads
715  return found;
716 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines