Add files via upload

This commit is contained in:
Godwin Ani 2023-11-13 16:25:52 -05:00 committed by GitHub
parent 1b587bf266
commit f292cf3cf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,8 +16,9 @@ parser.add_argument('-i', '--input')
parser.add_argument('-s', '--spreadsheet') parser.add_argument('-s', '--spreadsheet')
args = parser.parse_args() args = parser.parse_args()
os.makedirs(args.input + '/renamed', exist_ok = True) os.makedirs(args.input + '/renamed', exist_ok = True)
df = pd.read_csv(args.spreadsheet) df = pd.read_csv(args.spreadsheet, index_col = 0)
df = df.astype(str) df = df.astype(str)
df = df.applymap(lambda x: x.strip() if isinstance(x, str) else x)
df['Merged'] = df.apply(lambda row: '_'.join(row), axis=1) df['Merged'] = df.apply(lambda row: '_'.join(row), axis=1)
for file in os.listdir(args.input): for file in os.listdir(args.input):
if file.endswith('.tree') or file.endswith('.tre'): if file.endswith('.tree') or file.endswith('.tre'):
@ -29,7 +30,7 @@ for file in os.listdir(args.input):
tree = tree.replace('Len', 'L') tree = tree.replace('Len', 'L')
tree = tree.replace('Cov', 'Cv') tree = tree.replace('Cov', 'Cv')
tree = tree.replace('Contig', 'Ct') tree = tree.replace('Contig', 'Ct')
search_strings = df.iloc[:, 0].tolist() search_strings = df.index.tolist()
replacement_strings = df['Merged'].tolist() replacement_strings = df['Merged'].tolist()
for search, replace in zip(search_strings, replacement_strings): for search, replace in zip(search_strings, replacement_strings):
tree = tree.replace(search,replace) tree = tree.replace(search,replace)