Mercurial > repos > estrain > lissero
changeset 11:40f397e29951 draft
Uploaded
author | estrain |
---|---|
date | Thu, 08 Feb 2024 20:40:49 +0000 |
parents | 412d55f09755 |
children | 3ab7454298a4 |
files | lissero/lissero.xml lissero/variant4b.py |
diffstat | 2 files changed, 15 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/lissero/lissero.xml Thu Feb 08 18:18:47 2024 +0000 +++ b/lissero/lissero.xml Thu Feb 08 20:40:49 2024 +0000 @@ -9,7 +9,7 @@ --min_cov $settings.min_cov #end if '$input1' > output1; - python $__tool_directory__/variant4b.py output1 output2.txt; + python $__tool_directory__/variant4b.py output1 output2.txt ${input1.name}; ]]></command> <inputs> <param type="data" name="input1" format="fasta" />
--- a/lissero/variant4b.py Thu Feb 08 18:18:47 2024 +0000 +++ b/lissero/variant4b.py Thu Feb 08 20:40:49 2024 +0000 @@ -1,6 +1,6 @@ import sys -def identify_variants_with_genes(input_file_path, output_file_path): +def identify_variants_with_genes(input_file_path, output_file_path, simple_name): # Define the genes of interest genes_of_interest = ['LMO0737', 'ORF2110', 'ORF2819'] @@ -18,8 +18,11 @@ gene_indices = [headers.index(gene) for gene in genes_of_interest] serotype_index = headers.index('SEROTYPE') - # Initialize a list to hold the modified lines - modified_lines = [lines[0]] # Start with the header + # Modify the header to include the new first column + modified_header = f"FileName\t{lines[0]}" + + # Initialize a list to hold the modified lines, starting with the modified header + modified_lines = [modified_header] # Process each data line in the input file for line in lines[1:]: @@ -28,8 +31,10 @@ if all(data[index] == 'FULL' for index in gene_indices): # Modify the SEROTYPE column to "4b variant" data[serotype_index] = "4b variant" - # Rejoin the modified data into a single string and add it to the list - modified_lines.append('\t'.join(data) + '\n') + # Prepend the simple name to the line + modified_line = f"{simple_name}\t" + '\t'.join(data) + '\n' + # Add the modified line to the list + modified_lines.append(modified_line) # Write the modified lines to the output file with open(output_file_path, 'w') as file: @@ -38,11 +43,12 @@ print(f'Results written to {output_file_path}') if __name__ == "__main__": - if len(sys.argv) != 3: - print("Usage: python script.py <input_file_path> <output_file_path>") + if len(sys.argv) != 4: + print("Usage: python script.py <input_file_path> <output_file_path> <simple_name>") sys.exit(1) input_file_path = sys.argv[1] output_file_path = sys.argv[2] - identify_variants_with_genes(input_file_path, output_file_path) + simple_name = sys.argv[3] + identify_variants_with_genes(input_file_path, output_file_path, simple_name)