This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Truncated bamtofastq output files.

Hi, I am working with a mixed RNASeq data of plant and fungus. I aligned my Illumina paired-end reads using bowtie2, to one of the reference. I got mapped and unmapped.bam files. Now, I want to map these unmapped reads back to the second organism reference. I used samtools to sort the files by name using

$ samtools sort -n my_file_unmapped.bam -o my_file_unmapped.qsort -O BAM

and got, unmapped.qsort files. Visualized the files using samtools view,

$  samtools view Rs_Os1_1d_unmapped.qsort

D6B775P1:106:C4NARACXX:7:1101:2383:96122    69  *   0   255 *   *   0   0   CGGTGTTAGGCTTTCCATGACGATCGGTGTGGGAGGTGCCGTAGTTGTCAGTTGTGGACCCGGCACCGTAGCCGGCGGTAGTACTGCTGGTACCAGTAGT    BBBFFFFFFFFFFIIIIIIIIIIIIIIFFFFIIIIIFFIIIBFFIIIIIIIIIIIFFFFFFFFBFFFFFFFFFFFBFFBBFFFFFFFFFFFFFFFFFFFB
D6B775P1:106:C4NARACXX:7:1101:2383:96122    133 *   0   255 *   *   0   0   CAATCACAGGACGACAAATACCTACGGGTCGTCGAACACCAGTGACAACTACGGTTCAACTGACCGCACTCGCGGCACTGATCTGAACACCTGAACCGGA    BBBFFFFFFFFFFIIIIIIIIIIIIIIIBFFIIIIIFIIIIIFFFFFFFFBFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
D6B775P1:106:C4NARACXX:7:1101:2384:9664 69  *   0   255 *   *   0   0   AACACTGCTCGAGGTGCCATCGCGGATCGTCAGGCTATTGCCGAAGCTCTAAAGAGCGGGCAGATCAATGGATACGCCGGAGACGTGTGGGACGTTCAGC    BBBFFFFFFFFFFIFIIIIIIIIIIIIIIFIIIIIIIIIIIIFIFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFBFFFFFFFFBBFBFFFFFF<BFFFF
D6B775P1:106:C4NARACXX:7:1101:2384:9664 133 *   0   255 *   *   0   0   CCAGAGTAGTGGGGAACCATTCCGTTTCCTCCACCAAGAGGGTTCTTCATCGTGCGCCATGGATGGTCAGCAGGCGCTGGCTGAACGTCCCACACGTCTC    BBBFFFFFFFFFFIIIIIIIIIIIIIIIIIIIIIIIIIIIIIFIIIIIIIFFIIIIIIFFFFFFFFBFFFFFFFFFFFFFFFFFFBFBFFFFFFFFFFFF

Then I tried converting the .bam files to .fastq using bedtools bedtofastq

$ bedtools bamtofastq -i my_file_unmapped.qsort -fq my_file_unmapped.end1.fq -fq2 my_file_unmapped.end2.fq

Got 2 output files, my_file_unmapped.end1.fq my_file_unmapped.end2.fq But when I tried to visualize the file using samtools view, using the command

$ samtools view my_files_unmapped.end1.fq

I am getting the following error, [W::sam_read1] parse error at line 2; [main_samview] truncated file.

What am I doing wrong??

bamtofastq truncated output file

Why are you using samtools to view a plain fastq file (if the files have indeed been generated correctly)?

samtool view is not meant for fastq files. it is used for alignment files

Oh, now this is indeed a silly mistake. I should simply use "more" to visualize a fastq file in terminal.

use less filename command

@Prasad ok, thanks Prasad.

2 answers

Use BBSplit from BBMap as described here: BBSplit syntax for generating builds for the reference genome and how to call different builds.

yes, but after I use BBsplit, I obtain the fastq file and then I can to remap this with STAR but the count? FeatureCount doesn't work well with bbsplit. So my question is: After BBsplit What can I use to map and to calculate the count? Thanks

Why don't you just map again whole fastq files to other reference? First mapping to fungi and second to plant. Without parsing the unmapped bam files.

In such mixed data, sometimes reads are wrongly mapped to a reference and we get to know only when we go for annotation. I think i'll be better off using this approach.

Log in to answer this question.