Skip to content
Draft
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
2 changes: 1 addition & 1 deletion src/datahandlers/chembl.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def pull_labels(self,ofname):

# Sometimes the CHEMBL label is identical to the chemblid. We don't want those (https://github.com/TranslatorSRI/Babel/issues/430).
if label == chemblid:
continue
label = ''

outf.write(f'{CHEMBLCOMPOUND}:{chemblid}\t{label}\n')

Expand Down
20 changes: 16 additions & 4 deletions src/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ def load_synonyms(self,prefix):
with open(labelfname, 'r') as inf:
for line in inf:
x = line.strip().split('\t')
lbs[x[0]].add( ('http://www.geneontology.org/formats/oboInOwl#hasExactSynonym',x[1]) )
count_labels += 1
if len(x) == 1:
lbs[x[0]].add( ('http://www.geneontology.org/formats/oboInOwl#hasExactSynonym', '') )
elif len(x) == 2:
lbs[x[0]].add( ('http://www.geneontology.org/formats/oboInOwl#hasExactSynonym', x[1]) )
count_labels += 1
else:
logger.warning(f"Unexpected number of columns in {labelfname} ({len(x)}), skipping: {line.strip()}")
synfname = os.path.join(self.synonym_dir, prefix, 'synonyms')
if os.path.exists(synfname):
with open(synfname, 'r') as inf:
Expand Down Expand Up @@ -505,8 +510,15 @@ def load_extra_labels(self,prefix):
if os.path.exists(labelfname):
with open(labelfname,'r') as inf:
for line in inf:
x = line.strip().split('\t')
lbs[x[0]] = x[1]
x = line.strip().split('\t', maxsplit=1)
if len(x) == 1:
# We have an identifier, but we explicitly don't have a label.
lbs[x[0]] = ''
elif len(x) == 2:
# We have an identifier and a label.
lbs[x[0]] = x[1]
else:
logger.warning(f"bad line in {labelfname}: {line.strip()}")
self.extra_labels[prefix] = lbs

def apply_labels(self, input_identifiers, labels):
Expand Down