Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • m_elena_bioinfo
    Member
    • Oct 2009
    • 99

    #1

    read strand

    Hi NGS users,
    is there a way (by using bioperl module of samtools) to extract the information about the strand of the reads using a bam alignment?
    Thanx a lot!
    ME
  • Jose Blanca
    Member
    • Aug 2009
    • 70

    #2
    I don't know how to do it in perl, but I've done it in python using pysam. You can take a look at:
    franklin library for NGS sequencing analysis. Contribute to JoseBlanca/franklin development by creating an account on GitHub.


    The code that does the job is around lines 140 to 170 in the function _snvs_in_bam.

    Comment

    • kmcarr
      Senior Member
      • May 2008
      • 1181

      #3
      Originally posted by m_elena_bioinfo View Post
      Hi NGS users,
      is there a way (by using bioperl module of samtools) to extract the information about the strand of the reads using a bam alignment?
      Thanx a lot!
      ME
      Yes, here is some sample code:

      Code:
      #!/usr/bin/perl
      
      use strict;
      use warnings;
      
      use Bio::DB::Sam
      
      # Instantiate a new Bio::DB::Sam object, passing it the BAM file and the reference FASTA.
      
      my $sam = Bio::DB::Sam ->new(-bam=>"myPath/myBamFile.bam",
                                   -fasta=>"myPath/myFastaFile.fa");
      
      
      # Create a collection of alignment objects.  The arguments for get_features_by_location are seq_id (e.g. chrom name), start and end (1 based).
      
      
      my @alignments = $sam->get_features_by_location(-seq_id=>'chr1',
                                                      -start=>500,
                                                      -end=>15000);
      
      
      # Iterate over the aligments, querying each one for the strand of the read.
      
      for my $a (@alignments) {
      	
      	my $strand=$a->strand;
      	
      	# Do something with strand info.
      	
      	# You can also get seq_id, start, end, cigar string and much more about each alignment.
      	
      }

      Comment

      • m_elena_bioinfo
        Member
        • Oct 2009
        • 99

        #4
        Thank you very much for the rapid answers! Both are very useful!

        @kmcarr:in module Bio:B::Sam i found two different thing:
        my $strand=$a->strand;
        my $strand-query=$a->query->strand;

        What is the different? The query strand (the second variable) is the strand of the read?

        Comment

        • kmcarr
          Senior Member
          • May 2008
          • 1181

          #5
          Originally posted by m_elena_bioinfo View Post
          Thank you very much for the rapid answers! Both are very useful!

          @kmcarr:in module Bio:B::Sam i found two different thing:
          my $strand=$a->strand;
          my $strand-query=$a->query->strand;

          What is the different? The query strand (the second variable) is the strand of the read?
          By my reading of the APIs they are both giving you the same information, just from slightly different points of view. In the first case you are calling the strand method on a Bio:B::BAM::Alignment object, and in the second case you are calling the strand method within a Bio:B::BAM::Query object.

          In the first case strand reports whether the query sequence matches the forward (+1) or reverse (-1) strand of the reference. The second method reports whether or not the query sequence itself (+1) or the reverse complement of the query sequence (-1) matches the forward strand of the reference.

          Comment

          • m_elena_bioinfo
            Member
            • Oct 2009
            • 99

            #6
            Great Kmcarr, thanks for all the help you gave me.
            I tried to compare the two codes by extracting the strand of the reads in both methods. The results were the same!

            So I think that the only difference is the context and the module of bioperl that you use in your script!

            Comment

            Latest Articles

            Collapse

            • SEQadmin2
              New Genomics Technologies Take Aim at Long-Standing Limits
              by SEQadmin2


              Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

              We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
              ...
              09-28-2026, 10:25 AM
            • SEQadmin2
              How Immunogenomics Decodes Immunity’s Genetic Blueprint
              by SEQadmin2




              The immune system’s power comes from its genetic diversity, allowing myriad threats to be neutralized through first recognizing foreign antigens. That diversity is also what makes the immune system so difficult to study. Recent advances in sequencing technology and computational biology, however, are giving researchers new tools to understand immune responses and immune-related diseases in greater detail.

              This convergence of genetics, immunology, and computation...
              09-01-2026, 05:41 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, Yesterday, 09:51 AM
            0 responses
            12 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 09-25-2026, 09:06 AM
            0 responses
            35 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 09-23-2026, 11:05 AM
            0 responses
            28 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 09-18-2026, 11:37 AM
            1 response
            48 views
            0 reactions
            Last Post pekgio
            by pekgio
             
            Working...