sorting multiple .bam files in linux cluster
1
0
Entering edit mode
2.2 years ago
fatih • 0

I am working Linux cluster and ı have 1000 bam files under bam/ directory and they have pretty similar name bam_runid_bf2ff0593235864c9d423d28f1746a42d62df29e_0_0 and just first 0 changing into folder like 1,2,3,

I am wondering how can ı sort them as a single and merge them after indexing. I tried:

for f in bam/*_0.bam
do
  samtools sort -@ 7 $f ${f/bam/sorted}
done

what u advised but it did not worked. sorry ı am very new in this field .I generate a snakefile. When I try dry run with snakemake -n this error is shown

SyntaxError in line 2 of /cluster/lrcfs/2397405/projects/nanopore_testing/data/remoratrial/Snakefile: invalid syntax

When I type in working node same command samtools options are pop up my screen :( could you explain to me more simple? Thanks

bam samtools snakemake • 1.5k views
ADD COMMENT
1
Entering edit mode

Your samtools sort syntax is incorrect. it should be as follows (assuming rest of your loop is working as expected).

   samtools sort -@ 7 -o ${f/bam/sorted} $f

If there is snakemake involved (code for which you have not shown above) then there may be more to this than just samtools syntax.

ADD REPLY
2
Entering edit mode

Should it be ${f/.bam/.sorted.bam} instead?

ADD REPLY
0
Entering edit mode
2.2 years ago
fatih • 0

Hi all,

I find out that samtools default package (1.15.1) has issue with library (libtinfow.so.6: no version information availabl(required by samtools)) so if you change the version like 1.14.1, this command (for f in <folder>/*_0.bam; do samtools sort -@ 7 -o ${f/bam/sorted} $f; done`) is working fine.

ADD COMMENT

Login before adding your answer.

Traffic: 2518 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