Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gocamgen reporting changes and deleting gpad_extensions_mapper #542

Merged
merged 3 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading