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

def Bio::GenBank::_FeatureConsumer::_get_location (   self,
  range_info 
) [private]
Return a (possibly fuzzy) location from a Range object.

Arguments:
o range_info - A location range (ie. something like 67..100). This
may also be a single position (ie 27).

This returns a FeatureLocation object.
If parser.use_fuzziness is set at one, the positions for the
end points will possibly be fuzzy.

Definition at line 819 of file __init__.py.

                                       :
        """Return a (possibly fuzzy) location from a Range object.

        Arguments:
        o range_info - A location range (ie. something like 67..100). This
        may also be a single position (ie 27).

        This returns a FeatureLocation object.
        If parser.use_fuzziness is set at one, the positions for the
        end points will possibly be fuzzy.
        """
        if isinstance(range_info, LocationParser.Between) \
        and range_info.low.val+1 == range_info.high.val:
            #A between location like "67^68" (one based counting) is a
            #special case (note it has zero length). In python slice
            #notation this is 67:67, a zero length slice.  See Bug 2622
            pos = self._get_position(range_info.low)
            return SeqFeature.FeatureLocation(pos, pos)
            #NOTE - We can imagine between locations like "2^4", but this
            #is just "3".  Similarly, "2^5" is just "3..4"
        # check if we just have a single base
        elif not(isinstance(range_info, LocationParser.Range)):
            #A single base like "785" becomes [784:785] in python
            s_pos = self._get_position(range_info)
            # move the single position back one to be consistent with how
            # python indexes numbers (starting at 0)
            s_pos.position = s_pos.position  - 1
            e_pos = self._get_position(range_info)
            return SeqFeature.FeatureLocation(s_pos, e_pos)
        # otherwise we need to get both sides of the range
        else:
            # get *Position objects for the start and end
            start_pos = self._get_position(range_info.low)
            end_pos = self._get_position(range_info.high)

            start_pos.position, end_pos.position = \
              self._convert_to_python_numbers(start_pos.position,
                                              end_pos.position)
            #If the start location is a one-of position, we also need to
            #adjust their positions to use python counting.
            if isinstance(start_pos, SeqFeature.OneOfPosition) :
                for p in start_pos.position_choices :
                    p.position -= 1
                
            return SeqFeature.FeatureLocation(start_pos, end_pos)


Generated by  Doxygen 1.6.0   Back to index