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

Remove missing PDBs from ModuleIO #313

Merged
merged 4 commits into from
Feb 10, 2022
Merged
Changes from 3 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
23 changes: 22 additions & 1 deletion src/haddock/libs/libontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def check_faulty(self):
for element in self.output:
if isinstance(element, dict):
total += len(element.values())
present += sum([j.is_present() for j in element.values()])
present += sum(j.is_present() for j in element.values())
else:
total += 1
if element.is_present():
Expand All @@ -171,7 +171,28 @@ def check_faulty(self):

faulty_per = (1 - (present / total)) * 100

# added this method here to avoid modifying all calls in the
# modules' run method. We can think about restructure this part
# in the future.
self.remove_missing()

return faulty_per

def remove_missing(self):
"""Remove missing structure from `output`."""
# can't modify a list/dictionary within a loop
idxs = []
for idx, element in enumerate(self.output):
if isinstance(element, dict):
for key2 in list(element.keys()):
if not element[key2].is_present():
element.pop(key2)
else:
if not element.is_present():
idxs.append(idx)

for idx in idxs:
self.output.pop(idx)

def __repr__(self):
return f"Input: {self.input}{linesep}Output: {self.output}"