-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] extract pw relations from orthoxml
- Loading branch information
Showing
4 changed files
with
73 additions
and
6 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,34 @@ | ||
import argparse | ||
from ._config import logger_hog as logger | ||
from .zoo.utils import auto_open | ||
|
||
|
||
def extract_pw_rels(args): | ||
from lxml import etree | ||
from .zoo.hog import transform | ||
xml = etree.parse(args.orthoxml) | ||
with auto_open(args.out, 'wt') as fout: | ||
for p1, p2 in transform.iter_pairwise_relations(xml, rel_type=args.type, id_attribute="protId"): | ||
fout.write(f"{p1}\t{p2}\n") | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="FastOMA helper scripts") | ||
parser.add_argument('-v', default=0, action="count", help="increase verbosity") | ||
subparsers = parser.add_subparsers(required=True) | ||
|
||
parser_pw = subparsers.add_parser('pw-rel') | ||
parser_pw.add_argument("--type", choices=("ortholog", "paralog"), default="ortholog", | ||
help="Type of relations to extract. either 'ortholog' or 'paralog'") | ||
parser_pw.add_argument("--out", required=True, help="Path to output file") | ||
parser_pw.add_argument("--orthoxml", required=True, help="Path to input orthoxml file") | ||
parser_pw.set_defaults(func=extract_pw_rels) | ||
|
||
conf = parser.parse_args() | ||
logger.setLevel(level=30 - 10 * min(conf.v, 2)) | ||
logger.debug(conf) | ||
conf.func(conf) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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