This is a test version of Biostars. For the public version, visit https://www.biostars.org.
why is my txt file empty ?

Sorry friends,

I tried to convert a sam file produced by tophat2 to txt but the output txt file is empty...why?

[izadi@lbox161 tophat_out]$ cat accepted_hits.sam |grep -v ^@| awk '{print $3}' > accepted_hits.txt

Any suggestion please? I need the txt file for biophysconnector package

I also tried another command with bed file but the output txt is empty again

cat file.bed | awk '{print $1}' > file.txt
sam bam

2 answers

actually both of used commands worked but the issue was that the first there was no gene id in first column in which i expect to be extracted then normally the produced txt file seemed empty!!! i donno why when i used bed produced from converting the tophat2 bam the txt file was empty while when used the bed from bowtie2, the txt file was not empty..

TopHat outputs BAM files not SAM files - if you've converted the BAM file to a SAM file can you show me the command you used?

yes of course and the produced sam is not empty

the command:

[izadi@lbox161 ouput1]$ $SAM/samtools view -h accepted_hits.bam > accepted_hits.sam

do you know please how I can produce a txt file???? because I could display the average of reads by biophysconnector that needs two txt files from RNA-seq and ribo-seq and a bed file from ribo seq..then this package could extract the average of reads and show the graph...but I cant produce the txt file with sam nor bed

Providing there are actual alignments in your BAM file and TopHat didn't encounter errors you should be able to do the following:

samtools view your_file.bam | awk '{print $3}' > your_file.txt

This will give you a text file with the name of the reference sequence that your reads aligned to

thank you,

I tried your command but the txt file is empty again

just one column

I
I
I
I
I
I

so on

Can you show me a sample of your SAM file?

samtools view your_file.bam

Log in to answer this question.