Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bioperl adding tags to BAM aligned reads

    Hi everybody,

    I have a bam file and use bioperl (Bio:B::Sam) to work with it.
    Now i wanted to ask if there is any possibility to add tags to alignments in this File?

    i use

    Code:
            
    my $iterator     = $bam->features(-iterator => 1, -flags    => {M_UNMAPPED=>0});
    
    while (my $align = $iterator->next_seq) { 
            ...
    }
    to loop through the aligned reads and I am searching for anthing like

    Code:
    $align->addTag(key=>value)
    and i have one more question: is it possible to get the coverage of a segment using only the read start positions?

    Thx
    bye

  • #2
    I'm not sure about the first question, but for coverage you can use Bio:B::Sam::Segment (ignore smilie)
    Code:
     $segment = $sam->segment($seqid,$start,$end);
    to get coverage for the whole region.
    Code:
     # get coverage across this region
     my ($coverage)       = $segment->features('coverage');
     my @data_points      = $coverage->coverage;
    From the above, it looks like all you would need is $data_points[0] to get coverage at the start positions. Is that what you need?
    You may want to post this question to the bioperl list ([email protected]) if you don't find an answer on this forum. Someone will definitely help you there.

    Comment


    • #3
      no, that's not what i meant. your code would give you the coverage of the startposition of one segment. What i want is the coverage of the whole segment considering only startpositions of the reads. That means each read is considered as it would have length 1.

      Comment


      • #4
        Adding optional attributes to Goby alignment entries

        I am not sure about BAM alignments, but it is possible to add custom 'tags' to Goby alignment entries. You would simply do:


        Code:
                    final IterateAlignments iterator = new IterateAlignments() {
        
                        public void processAlignmentEntry(final AlignmentReader alignmentReader, final Alignments.AlignmentEntry alignmentEntry) {
        
                            int tagValue =???
        
                            final Alignments.AlignmentEntry revisedEntry = Alignments.AlignmentEntry.newBuilder()
                                    .mergeFrom(alignmentEntry).setMyTagValue(tagValue).build();
        
                            // do something with  revisedEntry
                        }
                    };
                    final String[] basenames = {"input1.entries", "input2.entries"};
        
                    iterator.parseIncludeReferenceArgument("1,2,X");
                    iterator.iterate(basenames);
        This assumes the attribute MyTagValue/my_tag_value has been defined on the alignment entry. You can simply

        1. add an optional tag attribute to the protobuff schema definition file (see goby/protobuf/Alignments.proto in the the Goby source code distribution), such as:

        optional int32 my_tag_value=1001;

        2. run protobuf/gensrc.sh to update the code to the new schema and you are ready to go. When defining pipeline specific attributes, please make the attributes optional and give attribute keys larger than 1000 (1001 in the example above).

        3. Create a new AlignmentEntry builder (revisedEntry), initialize it with values from alignmentEntry (calling mergeFrom), then set any new attributes as needed on revisedEntry. The call to build instructs the builder we are done making changes and returns a read-only alignment entry, which can be written to file, for instance or processed in some other way.

        Comment


        • #5
          hmm but that's java...

          as I said i am using bioperl and bam files....
          thx for your help, but that doesn't help me that much :-\

          Comment

          Latest Articles

          Collapse

          • seqadmin
            Current Approaches to Protein Sequencing
            by seqadmin


            Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
            04-04-2024, 04:25 PM
          • seqadmin
            Strategies for Sequencing Challenging Samples
            by seqadmin


            Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
            03-22-2024, 06:39 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, 04-11-2024, 12:08 PM
          0 responses
          27 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-10-2024, 10:19 PM
          0 responses
          31 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-10-2024, 09:21 AM
          0 responses
          27 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-04-2024, 09:00 AM
          0 responses
          52 views
          0 likes
          Last Post seqadmin  
          Working...
          X