Skip to content

Commit

Permalink
zoo.parse.parse_location more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
phiweger committed Mar 22, 2017
1 parent 58af441 commit fd81567
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions zoo/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,19 @@ def parse_date(date):
except (IndexError, ValueError):
continue
return record


def parse_location(location, source='genbank'):
'''
Example:
parse_gb_location('1->1374')
# ('1', '1374', 1) # start, end, fuzzy
'''
if source == 'genbank':
start, end = re.findall('\\d+', location)
fuzzy = int(any([i in location for i in ['>', '<']]))
return start, end, fuzzy
raise AttributeError('Unknown format.')


0 comments on commit fd81567

Please sign in to comment.