Trim bam file reads to the same length
2
1
Entering edit mode
4.8 years ago
rrapopor ▴ 40

Hi,

I have a bam file with vary reads length. I want to trim all the reads to the length of the shorter read in the file. I don't have access to to the fastq files, and the bam files went through many filters, so I prefer to do the trimming on the bam. Any idea how cam I do it?

Thanks!

RNA-Seq genome sequencing next-gen • 2.3k views
ADD COMMENT
2
Entering edit mode
4.8 years ago
GenoMax 147k

You could try using reformat.sh from BBMap suite. This is untested but may work.

reformat.sh in=your.bam out=new.bam maxlength=number_you_want
ADD COMMENT
0
Entering edit mode

Hi @genomax, please help check the following error. I have installed the bbmap and don't remove any files from the installion directory

reformat.sh in=test.bam out=test_short.bam maxlength=75
/histor/kang/yangpc/soft/01.NGS_data_process/bbmap//calcmem.sh: line 75: [: -v: unary operator expected
java -ea -Xms300m -cp /histor/kang/yangpc/soft/01.NGS_data_process/bbmap/current/ jgi.ReformatReads in=test.bam out=test_short.bam maxlength=75
Executing jgi.ReformatReads [in=test.bam, out=test_short.bam, maxlength=75]

Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Process.isAlive()Z
        at dna.Data.testExecute(Data.java:1828)
        at dna.Data.SAMBAMBA(Data.java:1710)
        at fileIO.ReadWrite.SAMBAMBA(ReadWrite.java:1898)
        at fileIO.ReadWrite.getInputStream(ReadWrite.java:840)
        at fileIO.ByteFile1.open(ByteFile1.java:330)
        at fileIO.ByteFile1.<init>(ByteFile1.java:100)
        at fileIO.ByteFile2$BF1Thread.<init>(ByteFile2.java:237)
        at fileIO.ByteFile2.open(ByteFile2.java:215)
        at fileIO.ByteFile2.<init>(ByteFile2.java:86)
        at fileIO.ByteFile.makeByteFile(ByteFile.java:35)
        at fileIO.ByteFile.makeByteFile(ByteFile.java:27)
        at stream.SamReadInputStream.<init>(SamReadInputStream.java:39)
        at stream.ConcurrentReadInputStream.getReadInputStream(ConcurrentReadInputStream.java:158)
        at stream.ConcurrentReadInputStream.getReadInputStream(ConcurrentReadInputStream.java:69)
        at jgi.ReformatReads.process(ReformatReads.java:480)
        at jgi.ReformatReads.main(ReformatReads.java:52)
ADD REPLY
0
Entering edit mode

Can you try?

reformat.sh -Xmx10g in=test.bam out=test_short.bam maxlength=75
ADD REPLY
0
Entering edit mode

Hi @genomax, it turned out to be the java version's problem. jdk1.8 work, but 1.7 failed. I modified the line 228 in the file bbmap/reformat.sh as following: local CMD="/path/to/java/jdk1.8.0_211/bin/java $EA $EOOM $z $z2 -cp $CP jgi.ReformatReads $@"

ADD REPLY
0
Entering edit mode

From the help maxlength=0 If nonzero, reads longer than this after trimming will be discarded.

From what i understand it does not want to remove the reads but trim supernumary nucleotide after a certain length

ADD REPLY
1
Entering edit mode
3.5 years ago
Juke34 8.9k

Using forcetrimright from bbmap it is possible to trim the reads to a choosen length

ADD COMMENT

Login before adding your answer.

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