6 from skbio
.alignment
import global_pairwise_align_nucleotide
10 if len(sys
.argv
) < 2 :
11 print('Usage:',sys
.argv
[0],'<bam file> >alignments.out',file=sys
.stderr
,flush
=True);
14 Adapters
= alignfq
.getAdapters()
16 with pysam
.AlignmentFile(bamFile
, "rb") as inbam
:
19 fqSeq
= aln
.get_forward_sequence()
22 aln
.reference_name
,':',
23 str(aln
.reference_start
),'+',
24 str(aln
.reference_length
),
34 alnSeq = str(DNA(alnSeq).reverse_complement())
36 eprint('-'.join('[x]',fqSeq,alnSeq))
38 maxAlignments
= alignfq
.aliOneSeq(Adapters
,fqSeq
)
39 alignfq
.printAli(maxAlignments
,fqSeq
,faID
)
41 if __name__
== "__main__":
42 main() # time ./alignbam.py t.multi.bam 2>/dev/null >t.multi.bam.adapterali