<p>you can do <code>samtools view pathtobamfile</code>, this will convert the file to <code>.sam</code> format and send it to <code>stdout</code>, the columns can then be parsed out which contain the information you are after.</p>

CC BY-SA 4.0
2019-08-14T04:46:13.873Z
2021-05-11T06:02:26.083Z
2021-05-11T06:02:26.083Z
user3479780
<p>The gff should have the coordinates for each feature.  I'd use featureCounts from subread to count up how many reads hit each feature.</p>

CC BY-SA 4.0
2019-08-14T22:58:55.043Z
2019-08-14T22:58:55.043Z
swbarnes2
<p>Apologies if this question is previously asked. I have a <code>BAM</code> file alignment to <code>hg19</code> and miRNA gff3 file from <code>mirbase</code> for annotation of BAM file. I want to extract information in the following format (e.g.):</p>
<pre><code>miRNA        chr    chr_start    chr_end    expression_count    sequence
hsa-mir-155  chr2       ...         ....         1020            ATGC....
</code></pre>
<p>I know that I can use htseq-count for BAM annotation and for expression counts but how can I get their chromosomal location. The reason for doing this specific way is that I want to show them in a CIRCOS plot.</p>
<p>Just counting is not the goal, their chromosomal location also needs to be extracted. So just subread/htseq-count is not sufficient for extracting genomic location information.</p>
<p>Previously, I had the same idea about processing the sam records. If I want to annotate chromosomal information with miRNA using .gff file, I have to check for each line in .sam records whether their chr_start and chr_end lie in the bandwidth of start and end of any miRNA in .gff file. This process can be very heavy and slow because .sam records are of more than 5 GB. That's why I want to know if there is any extremely fast and generalized way to do it.</p>
<p>I want to avoid processing sam records in python because my experience with extremely heavy data like fastq or sam in python is not good. I would rather prefer awk/bash or any low-level language.</p>
<p>Thanks.</p>

<sam><circos><chromosome-capture>
Chromosome information for miRNA
# Chromosome information for miRNA

(Asked by: username_0 on 2019-08-14)

Apologies if this question is previously asked. I have a BAM file alignment to hg19 and miRNA gff3 file from mirbase for annotation of BAM file. I want to extract information in the following format (e.g.):
miRNA        chr    chr_start    chr_end    expression_count    sequence
hsa-mir-155  chr2       ...         ....         1020            ATGC....

I know that I can use htseq-count for BAM annotation and for expression counts but how can I get their chromosomal location. The reason for doing this specific way is that I want to show them in a CIRCOS plot.
Just counting is not the goal, their chromosomal location also needs to be extracted. So just subread/htseq-count is not sufficient for extracting genomic location information.
Previously, I had the same idea about processing the sam records. If I want to annotate chromosomal information with miRNA using .gff file, I have to check for each line in .sam records whether their chr_start and chr_end lie in the bandwidth of start and end of any miRNA in .gff file. This process can be very heavy and slow because .sam records are of more than 5 GB. That's why I want to know if there is any extremely fast and generalized way to do it.
I want to avoid processing sam records in python because my experience with extremely heavy data like fastq or sam in python is not good. I would rather prefer awk/bash or any low-level language.
Thanks.

**Tags:** sam, circos, chromosome-capture

---

## 2 answers

### Answer by username_1 on 2019-08-14. Score: 1

you can do `samtools view pathtobamfile`, this will convert the file to `.sam` format and send it to `stdout`, the columns can then be parsed out which contain the information you are after.


---

### Answer by username_2 on 2019-08-14. Score: -1

The gff should have the coordinates for each feature. I'd use featureCounts from subread to count up how many reads hit each feature.


---

