int main (int *argc, char **argv) { char *tab; char *accession; SRAMgr const *sra; SRATable const *tbl; spotid_t nspots; rc_t rc; tab = argv[1]; accession = argv[2]; rc = openTable(tab, &sra, &tbl, &nspots); if (rc != 0) { return rc; } printf("There are %d spots\n", nspots); // rc = getReads(tbl, accession, 10); rc = getBases(tbl, 1, 10); if (rc != 0) { closeTable(sra, tbl); return 1; } printf("\n"); rc = getQuals(tbl, 1, 10); if (rc != 0) { closeTable(sra, tbl); return 1; } getInfo(tbl, 1, 10); getRanges(tbl); closeTable(sra, tbl); return 0; }
void printReadBuffered(aRead &rd,aHead *hd,kstring_t &str) { str.l = 0; if(bam_validate1(hd,rd)==0){ fprintf(stderr,"problems validateing\n"); exit(0); } kputsn((char *)rd.vDat,rd.l_qname-1,&str);kputc('\t', &str); kputw((int)rd.flag_nc>>16, &str); kputc('\t', &str); if(rd.refID==-1)//unmatched read kputc('*', &str); else kputs(hd->name[rd.refID] , &str); kputc('\t', &str); kputw(rd.pos+1, &str); kputc('\t', &str); kputw(rd.mapQ, &str);kputc('\t', &str); int nCigs = rd.nCig; if(nCigs==0) kputc('*', &str);// if no cigars else{ for (int i = 0; i < nCigs; ++i) {//print cigars uint32_t *cigs =getCig(&rd); kputw(cigs[i]>>BAM_CIGAR_SHIFT, &str); kputc("MIDNSHP"[cigs[i]&BAM_CIGAR_MASK], &str); } } kputc('\t', &str); if(rd.next_refID==-1) kputc('*', &str);// if no cigars else if(rd.refID==rd.next_refID) kputc('=', &str); else kputs(hd->name[rd.next_refID] , &str); kputc('\t', &str); kputw(rd.next_pos+1, &str); kputc('\t', &str); kputw(rd.tlen, &str); kputc('\t', &str); //start seq char *seq = (char *)getSeq(&rd); for(int i=0;i<rd.l_seq;i++) kputc(bam_nt16_rev_table2[bam1_seqi(seq, i)], &str); kputc('\t', &str); char *quals =(char *)getQuals(&rd); for(int i=0;i<rd.l_seq;i++) kputc(quals[i]+33, &str); //below is taken directly from samtools,(not to steal, to preserve ordering etc, all credits go where credit is due) //from aux start to the last memadrs in chunk printAuxBuffered(getAuxStart(&rd),rd.vDat+rd.block_size,str); kputc('\n', &str); }