From 9dff715e93c6a44b967809e1b82481ac68b9f957 Mon Sep 17 00:00:00 2001 From: spascarelli Date: Mon, 19 Aug 2024 14:56:51 +0200 Subject: [PATCH] Update OrthoXMLSplitter.py Irene and I modified the OrthoXML script so that it is easier to call it from the console. Please review and consider pulling --- utils/OrthoXMLSplitter.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/utils/OrthoXMLSplitter.py b/utils/OrthoXMLSplitter.py index 8103b19..5c85662 100644 --- a/utils/OrthoXMLSplitter.py +++ b/utils/OrthoXMLSplitter.py @@ -1,4 +1,4 @@ - +#!/usr/bin/env python3 # from pyoma project from __future__ import unicode_literals, division @@ -8,9 +8,11 @@ import errno import logging import re - +import argparse +import sys logger = logging.getLogger(__name__) + ## the only change compared to pyoma version is to remove int constratin on HOG id . @@ -228,4 +230,18 @@ def create_new_orthoxml(self, fn, OGs): tree = etree.ElementTree(etree_2_dump) tree.write( fn, xml_declaration=True, encoding="utf-8", method="xml", pretty_print=True - ) \ No newline at end of file + ) + +### main +def main(argv): + parser = argparse.ArgumentParser(description="Split OrthoXML file into HOGs") + parser.add_argument("-i", "--inFile", dest="inFile", required=True, help="OrthoXML file") + parser.add_argument("-o", "--outFile", dest="outFile", required=False, default='./splits/', help='split OrthoXML destination path') + args = parser.parse_args() + + splitter = OrthoXMLSplitter(args.inFile, cache_dir=args.outFile) + splitter() + +if __name__ == '__main__': + main(sys.argv) +