This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 changed file
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import glob | ||
|
||
import pandas as pd | ||
|
||
""" | ||
This method takes as input to | ||
@param path_to_prokka_output: Path to the output of prokka that contains the tsv files that will get concatenated | ||
@param output_path: Path to safe the final tsv file to. That tsv file can then used as input for keggcharter and has the columns with EC_number nad taxonomy | ||
""" | ||
|
||
|
||
def create_keggcharter_input(path_to_prokka_output, output_path): | ||
keggcharter_sheet = {'taxonomy': ['']} | ||
df = pd.DataFrame(keggcharter_sheet) | ||
df_list = [] | ||
df.to_csv(output_path, sep='\t') | ||
for tsv in glob.glob(f"{path_to_prokka_output}/tsvs/*.tsv"): | ||
data = pd.read_csv(tsv, sep='\t') | ||
tax = tsv.split('.tsv')[0] | ||
tax = tax.split('/')[-1] | ||
tax = tax.replace('_', ' ') | ||
tax = tax.replace('.fasta', ' ') | ||
print(tax) | ||
data["taxonomy"] = tax | ||
df_list.append(data) | ||
df = pd.concat(df_list) | ||
df.to_csv(output_path, sep='\t') | ||
|
||
# create_keggcharter_input("/Users/timolucas/Desktop/kegg_test/",'/Users/timolucas/Desktop/kegg_test/test.tsv') |