INNER CODE UNIT · C
isCHH
dpryan79/MethylDackel · common.c:77
inline int isCHH(char *seq, int pos, int seqlen) {
if(pos >= seqlen) return 0;
if(*(seq+pos) == 'C' || *(seq+pos) == 'c') return 1;
else if(*(seq+pos) == 'G' || *(seq+pos) == 'g') return -1;
return 0;
}
int getStrand(bam1_t *b) {
char *XG = (char *) bam_aux_get(b, "XG");
//Only bismark uses the XG tag like this. Some other aligners use it for other purposes...
if(XG != NULL && *(XG+1) != 'C' && *(XG+1) != 'G') XG = NULL;
if(XG == NULL) { //Can't handle non-directional libraries!
if(b->core.flag & BAM_FPAIRED) {
if((b->core.flag & 0x50) == 0x50) return 2; //Read1, reverse comp. == OB
else if(b->core.flag & 0x40) return 1; //Read1, forward == OT
else if((b->core.flag & 0x90) == 0x90) return 1; //Read2, reverse comp. == OT
else if(b->core.flag & 0x80) return 2; //Read2, forward == OB
return 0; //One of the above should be set!