ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/GBam.cpp
(Generate patch)
# Line 2 | Line 2
2   #include <ctype.h>
3   #include "kstring.h"
4  
5 < //auxiliary functions for BAM record handling
5 > //auxiliary functions for low level BAM record creation
6   uint8_t* realloc_bdata(bam1_t *b, int size) {
7    if (b->m_data < size) {
8          b->m_data = size;
# Line 32 | Line 32
32   GBamRecord::GBamRecord(const char* qname, int32_t gseq_tid,
33                   int pos, bool reverse, const char* qseq,
34                   const char* cigar, const char* quals):exons(1) {
35 <   novel=true;
35 >   //novel=true;
36     bam_header=NULL;
37     b=bam_init1();
38     b->core.tid=gseq_tid;
# Line 58 | Line 58
58               int pos, int map_qual, const char* cigar, int32_t mg_tid, int mate_pos,
59               int insert_size, const char* qseq, const char* quals,
60               GVec<char*>* aux_strings):exons(1)  {
61 <  novel=true;
61 >  //novel=true;
62    bam_header=NULL;
63    b=bam_init1();
64    b->core.tid=g_tid;
# Line 266 | Line 266
266             else if (op == BAM_CREF_SKIP) { //N
267                 //intron starts
268                 //exon ends here
269 <               exons.Add(new GSeg(exstart+1,l));
269 >               GSeg exon(exstart+1,c->pos+l);
270 >               exons.Add(exon);
271                 l += cigar[i]>>4;
272                 exstart=c->pos+l;
273                 }
274          }
275 <   exons.Add(new GSeg(exstart+1, l));
275 >   GSeg exon(exstart+1,c->pos+l);
276 >   exons.Add(exon);
277     end=c->pos+l;
278   }
279  
280   int GBamRecord::find_tag(const char tag[2], uint8_t* & s, char& tag_type) {
281     //position s at the beginning of tag "data" (after the type char)
282     //returns the length of tag data, and tag type in tag_type
283 <   s=bam1_aux(b);
284 <   while (s < b->data + b->data_len) {
283 >   uint8_t* aux_start=bam1_aux(b);
284 >   s=aux_start;
285 >   while (s < aux_start + b->l_aux - 1) {
286       char key[2];
287       key[0] = (char)s[0]; key[1] = (char)s[1];
288       s += 2; tag_type = (char)*s; ++s;
# Line 317 | Line 320
320                           { m_inc = 2; }
321             else if ('i' == sub_type || 'I' == sub_type || 'f' == sub_type)
322                           { m_inc = 4; }
323 <           if (m_inc==0) GError("Error: invalid 'B' array subtype (%c)!\n",sub_type);
323 >           if (m_inc==0)
324 >                 GError("Error: invalid 'B' array subtype (%c)!\n",sub_type);
325             inc += m_inc*n;
326             break;
327         case 'H':
# Line 327 | Line 331
331         } //switch (tag_type)
332       if (tag[0]==key[0] && tag[1]==key[1])
333          return inc;
334 +     s+=inc;
335       }//while aux data
336     return 0;
337     }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines