# HG changeset patch # User estrain # Date 1707416327 0 # Node ID 412d55f097555686c36457396775d65187d5fa38 # Parent 57d1d335ce8898f49a5c4add12f2ae6429465b4c Uploaded diff -r 57d1d335ce88 -r 412d55f09755 lissero.xml --- a/lissero.xml Tue Dec 13 18:43:42 2022 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ - - - lissero - - '$output1'; - ]]> - - - - - - - - - - - - - - - - - - - - - 10.1128/JCM.42.8.3819-3822.2004 - - diff -r 57d1d335ce88 -r 412d55f09755 lissero/lissero.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lissero/lissero.xml Thu Feb 08 18:18:47 2024 +0000 @@ -0,0 +1,52 @@ + + + lissero + + output1; + python $__tool_directory__/variant4b.py output1 output2.txt; + ]]> + + + + + + + + + + + + + + + + + + + + + 10.1128/JCM.42.8.3819-3822.2004 + + diff -r 57d1d335ce88 -r 412d55f09755 lissero/variant4b.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lissero/variant4b.py Thu Feb 08 18:18:47 2024 +0000 @@ -0,0 +1,48 @@ +import sys + +def identify_variants_with_genes(input_file_path, output_file_path): + # Define the genes of interest + genes_of_interest = ['LMO0737', 'ORF2110', 'ORF2819'] + + # Open the input file and read its lines + with open(input_file_path, 'r') as file: + lines = file.readlines() + + # Check if the file has more than just the header + if len(lines) <= 1: + print("Input file does not contain enough data.") + return + + # Extract the column headers and find the indices of the genes of interest + headers = lines[0].strip().split('\t') + 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 + + # Process each data line in the input file + for line in lines[1:]: + data = line.strip().split('\t') + # Check if the genes of interest are all present (marked as "FULL") + 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') + + # Write the modified lines to the output file + with open(output_file_path, 'w') as file: + file.writelines(modified_lines) + + print(f'Results written to {output_file_path}') + +if __name__ == "__main__": + if len(sys.argv) != 3: + 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) +