Closed sagitaninta closed 1 year ago
Hi, is there a dictionary IN the BAM header (lines starting with @SQ ) ?
also, please send a minimal bam file with the header and the first read.
To answer the first question, yes, there are dictionary in the BAM header. They are these ones right?
samtools view -H SRR7107779_mdup_test.bam | grep "@SQ" | head
@SQ SN:1 LN:122678785
@SQ SN:2 LN:85426708
@SQ SN:3 LN:91889043
@SQ SN:4 LN:88276631
@SQ SN:5 LN:88915250
@SQ SN:6 LN:77573801
@SQ SN:7 LN:80974532
@SQ SN:8 LN:74330416
@SQ SN:9 LN:61074082
@SQ SN:10 LN:69331447
Attached the minimum BAM as txt; you can rename the extension as .bam and ran it with bamrenamechr.jar
and it will behave the same, at least in my side. I hope that works as GitHub do not like .bam extension.
SRR7107779_mdup_test.txt
works on my machine.
cat SRR*.txt | samtools view -O BAM -o jeter.bam
samtools index jeter.bam
samtools idxstats jeter.bam | grep -v -F '*' | awk '{printf("%s\tchr%s\n",$1,$1);}' > jeter2.txt
$ java -jar dist/bamrenamechr.jar -f jeter2.txt jeter.bam | grep chr | tail -1 && echo OK
[WARN][ConvertBamChromosomes]num ignored read:0
SRR7107779.93158088 147 chr38 14665040 60 18S71M = 14664718 -393 TTATAGTTTCCTGGTCCCCCTTCTGGCCACCCCTTCCTCCACAGCATGTCCTTGCCATCCCTCGAGCCGTCATCTTGAAGGACACAGTG ###############################98::995:9:8:899:8:98:88999999992899;39;;;;;;;:;;::9;9;::<; MC:Z:21M1I79M MD:Z:12A58 PG:Z:MarkDuplicates RG:Z:SRR7107779_1 length=101 NM:i:1 AS:i:66 XS:i:19
OK
That line with samtools idxstats
is the one I need to make it work! Thanks. I foolishly just do the first two chromosomes following exactly the example in the docs 🤪
I am closing this, thank you very much for your time.
Cannot make bamrenamechr work
I just want to rename the chromosomes in my BAM file from only number to having "chr" prefix, but it does not work. Possibly just because I do not know how to run it based from the documentation. I do not know where to get that toy.sam as I have my samtools from conda environment.
Basically, this is what I run with my BAM file, and what I got:
Then, I tried to make a dictionary, both with or without chromosome prefix, but got that message.
Your environment
version of jvarkit java -jar ~/bin/jvarkit/dist/bamrenamechr.jar --version 3f7bba5f9
version of java java -version openjdk version "1.8.0_152-release" OpenJDK Runtime Environment (build 1.8.0_152-release-1056-b12) OpenJDK 64-Bit Server VM (build 25.152-b12, mixed mode)
the value of
${JAVA_HOME}
/dss/dsshome1/lxc06/ra57gih/.conda/envs/gatk4_envwhich OS Linux