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

def Bio::GenBank::_FeatureConsumer::_get_position (   self,
  position 
) [private]

Return a (possibly fuzzy) position for a single coordinate.

Arguments:
o position - This is a LocationParser.* object that specifies
a single coordinate. We will examine the object to determine
the fuzziness of the position.

This is used with _get_location to parse out a location of any
end_point of arbitrary fuzziness.

Definition at line 791 of file __init__.py.

00791                                      :
        """Return a (possibly fuzzy) position for a single coordinate.

        Arguments:
        o position - This is a LocationParser.* object that specifies
        a single coordinate. We will examine the object to determine
        the fuzziness of the position.

        This is used with _get_location to parse out a location of any
        end_point of arbitrary fuzziness.
        """
        from Bio import SeqFeature
        from Bio.GenBank import LocationParser
        # case 1 -- just a normal number
        if (isinstance(position, LocationParser.Integer)):
            final_pos = SeqFeature.ExactPosition(position.val) 
        # case 2 -- we've got a > sign
        elif isinstance(position, LocationParser.LowBound):
            final_pos = SeqFeature.AfterPosition(position.base.val)
        # case 3 -- we've got a < sign
        elif isinstance(position, LocationParser.HighBound):
            final_pos = SeqFeature.BeforePosition(position.base.val)
        # case 4 -- we've got 100^101
        elif isinstance(position, LocationParser.Between):
            final_pos = SeqFeature.BetweenPosition(position.low.val,
                                                 position.high.val)
        # case 5 -- we've got (100.101)
        elif isinstance(position, LocationParser.TwoBound):
            final_pos = SeqFeature.WithinPosition(position.low.val,
                                                position.high.val)
        # case 6 -- we've got a one-of(100, 110) location
        elif isinstance(position, LocationParser.Function) and \
                        position.name == "one-of":
            # first convert all of the arguments to positions
            position_choices = []
            for arg in position.args:
                # we only handle AbsoluteLocations with no path
                # right now. Not sure if other cases will pop up
                assert isinstance(arg, LocationParser.AbsoluteLocation), \
                  "Unhandled Location type %r" % arg
                assert arg.path is None, "Unhandled path in location"
                position = self._get_position(arg.local_location)
                position_choices.append(position)
            final_pos = SeqFeature.OneOfPosition(position_choices)
        # if it is none of these cases we've got a problem!
        else:
            raise ValueError("Unexpected LocationParser object %r" %
                             position)

        # if we are using fuzziness return what we've got
        if self._use_fuzziness:
            return final_pos
        # otherwise return an ExactPosition equivalent
        else:
            return SeqFeature.ExactPosition(final_pos.location)

    def _add_qualifier(self):


Generated by  Doxygen 1.6.0   Back to index