Skip to content

Commit

Permalink
Merge pull request #542 from biolink/gocamgen
Browse files Browse the repository at this point in the history
Gocamgen reporting changes and deleting gpad_extensions_mapper
  • Loading branch information
dougli1sqrd committed Mar 24, 2021
2 parents 20dc806 + d30d7ea commit 0ec3aa6
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 788 deletions.
14 changes: 13 additions & 1 deletion ontobio/rdfgen/gocamgen/errors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from ontobio.rdfgen.gocamgen import collapsed_assoc


class GocamgenException(Exception):
def __init__(self, message):
def __init__(self, message: str):
self.message = message

def __str__(self):
Expand All @@ -14,6 +17,15 @@ class ShexException(GocamgenException):
pass


class CollapsedAssocGocamgenException(GocamgenException):
def __init__(self, message: str, assoc: collapsed_assoc.CollapsedAssociation):
self.message = message
self.assoc = assoc

def __str__(self):
return "{}\n{}".format(self.message, "\n".join([l.source_line for l in self.assoc.lines]))


class GeneErrorSet:
def __init__(self):
self.errors = {}
Expand Down
6 changes: 4 additions & 2 deletions ontobio/rdfgen/gocamgen/gocam_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def make_model(self, gene, annotations: List[GoAssociation], output_directory=No
model.write(out_filename)
logger.info("Model for {} written to {} in {} sec".format(gene, out_filename,
(time.time() - start_time)))
for err in model.errors:
self.errors.add_error(gene, err)
return model
except GocamgenException as ex:
self.errors.add_error(gene, ex)
Expand Down Expand Up @@ -156,13 +158,13 @@ def parse_gpi(gpi_file):
class AssocExtractor:
def __init__(self, gpad_file, parser_config: AssocParserConfig):
self.assocs = []
gpad_parser = gpadparser.GpadParser(config=parser_config)
self.gpad_parser = gpadparser.GpadParser(config=parser_config)
with open(gpad_file) as sg:
lines = sum(1 for line in sg)

with open(gpad_file) as gf:
click.echo("Making products...")
with click.progressbar(iterable=gpad_parser.association_generator(file=gf, skipheader=True),
with click.progressbar(iterable=self.gpad_parser.association_generator(file=gf, skipheader=True),
length=lines) as associations:
self.assocs = list(associations)

Expand Down

0 comments on commit 0ec3aa6

Please sign in to comment.