# HG changeset patch # User estrain # Date 1707424849 0 # Node ID 40f397e29951b50e7e698105b51f95d88e7aa2d0 # Parent 412d55f097555686c36457396775d65187d5fa38 Uploaded diff -r 412d55f09755 -r 40f397e29951 lissero/lissero.xml --- 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}; ]]> diff -r 412d55f09755 -r 40f397e29951 lissero/variant4b.py --- 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 ") + if len(sys.argv) != 4: + print("Usage: python script.py ") 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)