ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/GBam.cpp
(Generate patch)
# Line 275 | Line 275
275     exons.Add(exon);
276     end=c->pos+l;
277   }
278 <
278 > /*
279   int GBamRecord::find_tag(const char tag[2], uint8_t* & s, char& tag_type) {
280     //position s at the beginning of tag "data" (after the type char)
281     //returns the length of tag data, and tag type in tag_type
# Line 336 | Line 336
336       }//while aux data
337     return 0;
338     }
339 + */
340 + uint8_t* GBamRecord::find_tag(const char tag[2]) {
341 +   return bam_aux_get(this->b, tag);
342 + }
343  
344   char GBamRecord::tag_char(const char tag[2]) { //retrieve tag data as single char
345 <   uint8_t *s;
346 <   char tag_type=0;
347 <   int vlen=find_tag(tag, s, tag_type);
344 <   if (vlen==0) return 0;
345 <   //if (vlen>1) GWarning("Warning: tag %c%c value has length %d, but char was expected.\n",
346 <   //        tag[0],tag[1],vlen);
347 <   return (char)s[0];
345 >   uint8_t* s=find_tag(tag);
346 >   if (s) return ( bam_aux2A(s) );
347 >   return 0;
348    }
349  
350   int GBamRecord::tag_int(const char tag[2]) { //get the numeric value of tag
351 <   uint8_t *s;
352 <   char tag_type=0;
353 <   int vlen=find_tag(tag, s, tag_type);
354 <   if (vlen==0) return 0;
355 <   if (vlen==1) return (int)(*(int8_t*)s);
356 <    else if (vlen==2) return (int)(*(int16_t*)s);
357 <     else if (vlen==4) return (int)(*(int32_t*)s);
358 <     else GMessage("Warning: tag %c%c value has length %d, but int type was expected.\n",
359 <           tag[0],tag[1], vlen);
351 >   uint8_t *s=find_tag(tag);
352 >   if (s) return ( bam_aux2i(s) );
353     return 0;
354     }
355  
356   char* GBamRecord::tag_str(const char tag[2]) { //return string value for a tag
357 <   uint8_t *s;
358 <   char tag_type=0;
359 <   int vlen=find_tag(tag, s, tag_type);
367 <   if (vlen==0) return NULL; //not found
368 <   //if (vlen>1) GWarning("Warning: tag %c%c value has length %d, but char was expected.\n",
369 <   //        tag[0],tag[1],vlen);
370 <   return (char *)s;
357 >   uint8_t *s=find_tag(tag);
358 >   if (s) return ( bam_aux2Z(s) );
359 >   return NULL;
360     }
361  
362   char GBamRecord::spliceStrand() { // '+', '-' from the XS tag, or 0 if no XS tag
363 <   uint8_t *s;
364 <   char tag_type=0;
365 <   int vlen=find_tag("XS", s, tag_type);
377 <   if (vlen==0) return '.';
378 <   return (char)s[0];
363 >   char c=tag_char("XS");
364 >   if (c) return c;
365 >     else return '.';
366     }
367  
368   char* GBamRecord::sequence() { //user must free this after use

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines