mirror of
http://43.156.76.180:8026/YuuMJ/EukPhylo.git
synced 2026-02-11 09:50:25 +08:00
Updating arg parsing in tip counting script
This commit is contained in:
parent
2280edaf5a
commit
9d07bca28c
@ -1,6 +1,6 @@
|
|||||||
'''
|
'''
|
||||||
Author: Auden Cote-L'Heureux
|
Author: Auden Cote-L'Heureux
|
||||||
Last updated: 06/14/23 by Elinor
|
Last updated: 10/24/23
|
||||||
Motivation: Count the number of occurences of each taxa in each OG in a post guidance file
|
Motivation: Count the number of occurences of each taxa in each OG in a post guidance file
|
||||||
Dependencies: Bio python, os, sys
|
Dependencies: Bio python, os, sys
|
||||||
Inputs: Directory of postguidance files
|
Inputs: Directory of postguidance files
|
||||||
@ -15,31 +15,22 @@ from Bio import SeqIO
|
|||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
|
|
||||||
in_dir = ''
|
parser = argparse.ArgumentParser(
|
||||||
|
prog = 'Tip counting script',
|
||||||
if('--input' in sys.argv or '-i' in sys.argv):
|
description = "Updated Oct 24th, 2023 by Auden Cote-L'Heureux."
|
||||||
try:
|
)
|
||||||
if('--input' in sys.argv):
|
|
||||||
in_dir = sys.argv[sys.argv.index('--input') + 1]
|
parser.add_argument('-i', '--input', type = str, required = True, help = 'Path to the folder containing the input trees')
|
||||||
else:
|
args = parser.parse_args()
|
||||||
in_dir = sys.argv[sys.argv.index('-i') + 1]
|
|
||||||
except IndexError:
|
|
||||||
print('\nError: Something went wrong went parsing the arguments... maybe you forgot to input an input directory of trees?\n')
|
|
||||||
print('\nPlease input a folder of .tre files:\n\n\tpython count_tips.py --input <path/to/folder>\n')
|
|
||||||
exit()
|
|
||||||
else:
|
|
||||||
print('\nPlease input a folder of .tre files:\n\n\tpython count_tips.py --input <path/to/folder>\n')
|
|
||||||
exit()
|
|
||||||
|
|
||||||
|
if(args.input.endswith('/')):
|
||||||
|
args.input = args.input[:-1]
|
||||||
|
|
||||||
if(in_dir.endswith('/')):
|
if(not os.path.isdir(args.input)):
|
||||||
in_dir = in_dir[:-1]
|
print('\nThe input folder (--input) could not be found. Make sure you have given the correct path.\n')
|
||||||
|
|
||||||
if(not os.path.isdir(in_dir)):
|
|
||||||
print('\nPlease input a folder of .tre files:\n\n\tpython count_tips.py --input <path/to/folder>\n')
|
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
return in_dir
|
return args.input
|
||||||
|
|
||||||
|
|
||||||
def count_tips(in_dir):
|
def count_tips(in_dir):
|
||||||
@ -79,4 +70,4 @@ def main():
|
|||||||
count_tips(in_dir)
|
count_tips(in_dir)
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user