biolink / ontobio

python library for working with ontologies and ontology associations
https://ontobio.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
119 stars 30 forks source link

Support YYYY-MM-DD format in test for GORULE:0000029 #493

Closed dustine32 closed 3 years ago

dustine32 commented 3 years ago

When parsing this GPAD 2.0 line:

MGI:MGI:1914305         RO:0002264      GO:0001933      MGI:MGI:5514426|PMID:23986251   ECO:0000314                     2014-05-20      MGI             creation-date=2014-05-20|modification-date=2014-05-20|contributor-id=http://orcid.org/0000-0003-3394-9805

I get:

Traceback (most recent call last):
  File "gpad2gaf.py", line 22, in <module>
    assocs: List[GoAssociation] = gpad_parser.parse(args.gpad_path, skipheader=True)
  File "/Users/ebertdu/go/ontobio/ontobio/io/assocparser.py", line 464, in parse
    a = list(associations)
  File "/Users/ebertdu/go/ontobio/ontobio/io/assocparser.py", line 477, in association_generator
    parsed_result = self.parse_line(line)
  File "/Users/ebertdu/go/ontobio/ontobio/io/gpadparser.py", line 150, in parse_line
    go_rule_results = qc.test_go_rules(assoc, self.config)
  File "/Users/ebertdu/go/ontobio/ontobio/io/qc.py", line 705, in test_go_rules
    result = rule.value.run_test(active_annotation, config, group=group)
  File "/Users/ebertdu/go/ontobio/ontobio/io/qc.py", line 87, in run_test
    result = self._run_if_context(annotation, config, group=group)
  File "/Users/ebertdu/go/ontobio/ontobio/io/qc.py", line 82, in _run_if_context
    result = self.test(annotation, config, group=group)
  File "/Users/ebertdu/go/ontobio/ontobio/io/qc.py", line 390, in test
    int(date[6:8]),
ValueError: invalid literal for int() with base 10: '5-'

It's choking on the 2014-05-20 date field due to the coded indices here: https://github.com/biolink/ontobio/blob/9ac3a06bc67672e2576ced7eb8c0c232668451c6/ontobio/io/qc.py#L388-L391

So we'll need to update this to allow date format in GPAD 2.0 spec

@dougli1sqrd I can PR a change and test.

dougli1sqrd commented 3 years ago

oh thanks, good catch!

sierra-moxon commented 3 years ago

fixed via PR above.