Logo Search packages:      
Sourcecode: python-biopython version File versions  Download package

def Bio::AlignIO::FastaIO::FastaM10Iterator::_extract_alignment_region (   self,
  alignment_seq_with_flanking,
  annotation 
) [private]
Helper function for the main parsing code.

To get the actual pairwise alignment sequences, we must first
translate the un-gapped sequence based coordinates into positions
in the gapped sequence (which may have a flanking region shown
using leading - characters).  To date, I have never seen any
trailing flanking region shown in the m10 file, but the
following code should also cope with that.

Note that this code seems to work fine even when the "sq_offset"
entries are prsent as a result of using the -X command line option.

Definition at line 399 of file FastaIO.py.

                                                                                 :
        """Helper function for the main parsing code.

        To get the actual pairwise alignment sequences, we must first
        translate the un-gapped sequence based coordinates into positions
        in the gapped sequence (which may have a flanking region shown
        using leading - characters).  To date, I have never seen any
        trailing flanking region shown in the m10 file, but the
        following code should also cope with that.

        Note that this code seems to work fine even when the "sq_offset"
        entries are prsent as a result of using the -X command line option.
        """
        align_stripped = alignment_seq_with_flanking.strip("-")
        display_start = int(annotation['al_display_start'])
        if int(annotation['al_start']) <= int(annotation['al_stop']) :
            start = int(annotation['al_start']) \
                  - display_start
            end   = int(annotation['al_stop']) \
                  - display_start \
                  + align_stripped.count("-") + 1
        else :
            #FASTA has flipped this sequence...
            start = display_start \
                  - int(annotation['al_start'])
            end   = display_start \
                  - int(annotation['al_stop']) \
                  + align_stripped.count("-") + 1
        assert 0 <= start and start < end and end <= len(align_stripped), \
               "Problem with sequence start/stop,\n%s[%i:%i]\n%s" \
               % (alignment_seq_with_flanking, start, end, annotation)
        return align_stripped[start:end]



Generated by  Doxygen 1.6.0   Back to index