Parse out location information from the location string. This uses Andrew's nice spark based parser to do the parsing for us, and translates the results of the parse into appropriate Location objects.
00570 : """Parse out location information from the location string. This uses Andrew's nice spark based parser to do the parsing for us, and translates the results of the parse into appropriate Location objects. """ from Bio.GenBank import LocationParser # --- first preprocess the location for the spark parser # we need to clean up newlines and other whitespace inside # the location before feeding it to the parser. # locations should have no whitespace whatsoever based on the # grammer location_line = self._clean_location(content) # Older records have junk like replace(266,"c") in the # location line. Newer records just replace this with # the number 266 and have the information in a more reasonable # place. So we'll just grab out the number and feed this to the # parser. We shouldn't really be losing any info this way. if location_line.find('replace') != -1: comma_pos = location_line.find(',') location_line = location_line[8:comma_pos] # feed everything into the scanner and parser try: parse_info = \ LocationParser.parse(LocationParser.scan(location_line)) # spark raises SystemExit errors when parsing fails except SystemExit: raise LocationParserError(location_line) # print "parse_info:", repr(parse_info) # add the parser information the current feature self._set_location_info(parse_info, self._cur_feature) def _set_function(self, function, cur_feature):