-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
117 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- "DB" | ||
- "DB_Object_ID" | ||
- "DB_Object_Symbol" | ||
- "DB_Object_Name" | ||
- "DB_Object_Synonym(s)" | ||
- "DB_Object_Type" | ||
- "Taxon" | ||
- "Parent_Object_ID" | ||
- "DB_Xref(s)" | ||
- "Properties" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
- "SUBJECT" | ||
- "SUBJECT_LABEL" | ||
- "SUBJECT_TAXON" | ||
- "SUBJECT_TAXON_LABEL" | ||
- "OBJECT" | ||
- "OBJECT_LABEL" | ||
- "RELATION" | ||
- "RELATION_LABEL" | ||
- "EVIDENCE" | ||
- "EVIDENCE_LABEL" | ||
- "SOURCE" | ||
- "IS_DEFINED_BY" | ||
- "QUALIFIER" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- 'protein1' | ||
- 'protein2' | ||
- 'neighborhood' | ||
- 'fusion' | ||
- 'cooccurence' | ||
- 'coexpression' | ||
- 'experimental' | ||
- 'database' | ||
- 'textmining' | ||
- 'combined_score' : 'int' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
Custom PyYaml loaders to add support for | ||
unique key checking and including/importing other yaml files via | ||
an 'include!' tag, eg | ||
x: !include some-other.yaml | ||
y: 1 | ||
Unique key loader based on: https://stackoverflow.com/a/63215043 | ||
Include loader based on: https://matthewpburruss.com/post/yaml/ | ||
""" | ||
|
||
import yaml | ||
from yaml import SafeLoader | ||
from yaml.constructor import ConstructorError | ||
from typing import Union, IO | ||
|
||
from koza.io.utils import open_resource | ||
|
||
|
||
class UniqueIncludeLoader(SafeLoader): | ||
""" | ||
YAML Loader with additional support for | ||
- checking for duplicate keys | ||
- an '!include' tag for importing other yaml files | ||
""" | ||
|
||
def unique_construct_mapping(self, node: yaml.Node, deep=False): | ||
mapping = [] | ||
for key_node, value_node in node.value: | ||
key = self.construct_object(key_node, deep=deep) | ||
if key in mapping: | ||
raise ConstructorError( | ||
f"while constructing a mapping for {value_node.value} " | ||
f"found duplicate key {key}" | ||
) | ||
mapping.append(key) | ||
return super().construct_mapping(node, deep) | ||
|
||
def include_constructor(self, node: yaml.Node) -> Union[str, IO[str]]: | ||
""" | ||
Opens some resource (local or remote file) that appears after an !include tag | ||
""" | ||
return yaml.load(open_resource(self.construct_scalar(node)), Loader=UniqueIncludeLoader) | ||
|
||
|
||
yaml.add_constructor('!include', UniqueIncludeLoader.include_constructor, UniqueIncludeLoader) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters