Parsing sam file
0
0
Entering edit mode
10.3 years ago
Sidney • 0

I have no idea on how to start the program.

Question is:

Write a Perl program that parses out the attached sequence read alignment file (6.SAM) to count how many reads a gene produced.

Output should be :

Gene ID:            Number of reads aligning:
gene29              3
gene27              6
alignment perl • 3.7k views
ADD COMMENT
5
Entering edit mode

Homework???

ADD REPLY
0
Entering edit mode

all his other posts seem to have been

ADD REPLY
0
Entering edit mode

Practice exercises, but I am trying to simply understand how to go about solving since I do not understand the question. So far I have :

foreach my $id (@{$ids}) {
    my $alignments = $sam -> get_features_by_location(-seq_id => $transcript_id, -iterator => 1);

    while (my $alignment = $alignments -> next_seq) {
        my $read_name = $alignment -> query -> name;

        if (exists($global_read_occurrences{$read_name})) {
            $global_read_occurrences{$read_name}++;
        }
        else {
            $global_read_occurrences{$read_name} = 1;
        }
    }
}
ADD REPLY
0
Entering edit mode

What do you interpret the question as meaning? We can start by simply telling you if your interpretation of the program you need to write is correct or not. Also, can you post a line or two of the SAM file? I'm guessing that it's aligned to the transcriptome, but if not that'll change a bit how the program would work.

ADD REPLY
0
Entering edit mode

You don't need that 'if' statement.

$hash{whatever}++;

works fine whether or not 'whatever' is a key in the hash already.

For people not doing perl homework, samtools idxstats will count this up for you, you could also do it with unix tools: cut, sort, uniq -c, sort

ADD REPLY
0
Entering edit mode

I love perl, but anyone assigning students perl homework is mad.

ADD REPLY

Login before adding your answer.

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