samsift can't find the AS tag to filter a bam file generated using bowtie2
0
0
Entering edit mode
9 months ago

Using samsift I've successfully filtered bam files generated by alignment using bwa mem. However, it doesn't seem to work for bowtie2.

Here's the script:

REF="/Users/michaelflower/refs/rep/HTTset20_CAG0500.fasta"
OUT="/Users/michaelflower/my_bin/amplicon_repeat_seq/cassio_results"
FN="Flower_n7m_3_FSC1_Linear_2950"
METHOD="bowtie2"
my_sam="${OUT}/${FN}.${METHOD}.sam"
my_bam="${OUT}/${FN}.${METHOD}.bam"

bowtie2 -x "$REF" -U "$R1" -S "${OUT}/${FN}.${METHOD}.sam"

samtools sort "${my_sam}" > "${my_sam%.*}.bam"
samtools index "${my_sam%.*}.bam"
samtools flagstat "${my_sam%.*}.bam" > "${my_sam%.*}.flagstat.txt"

samsift -i "${my_bam}" -o "${my_bam%.*}.filtered.bam" -f 'AS>94'

Here's the error:

$ samsift -i "${my_bam}" -o "${my_bam%.*}.filtered.bam" -f 'AS>94'
[samsift] 2024-02-28 22:08:41 SAMsift is starting.
Traceback (most recent call last):
  File "/Users/michaelflower/micromamba/envs/bioinfo/bin/samsift", line 10, in <module>
    sys.exit(main())
  File "/Users/michaelflower/micromamba/envs/bioinfo/lib/python3.10/site-packages/samsift/samsift.py", line 418, in main
    sam_sift.run()
  File "/Users/michaelflower/micromamba/envs/bioinfo/lib/python3.10/site-packages/samsift/samsift.py", line 283, in run
    self.process_alignment(alignment)
  File "/Users/michaelflower/micromamba/envs/bioinfo/lib/python3.10/site-packages/samsift/samsift.py", line 248, in process_alignment
    self._filter()
  File "/Users/michaelflower/micromamba/envs/bioinfo/lib/python3.10/site-packages/samsift/samsift.py", line 182, in _filter
    self.passes=eval(self.filter, self.vardict)
  File "<string>", line 1, in <module>
NameError: name 'AS' is not defined

I had a similar issue with minimap2 that was solved by adding the --sam-hit-only tag.

I can't find an answer online or on readmes, so any help would be great!

samsift bowtie2 • 293 views
ADD COMMENT
0
Entering edit mode

what is AS ? an attribute in a SAM record? Are you sure this is the way to access an attribute : -f 'AS>94' . Otherwise, just use samtools view --expr 'something'

ADD REPLY

Login before adding your answer.

Traffic: 1604 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6