Skip to content

Commit

Permalink
Handle cases where stop codon is X, not *
Browse files Browse the repository at this point in the history
  • Loading branch information
susannasiebert committed Apr 20, 2018
1 parent cb48197 commit 964bb04
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/fasta_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,14 @@ def execute(self):
wildtype_amino_acid, mutant_amino_acid = line['amino_acid_change'].split('/')
if '*' in wildtype_amino_acid:
wildtype_amino_acid = wildtype_amino_acid.split('*')[0]
elif 'X' in wildtype_amino_acid:
wildtype_amino_acid = wildtype_amino_acid.split('X')[0]
if '*' in mutant_amino_acid:
mutant_amino_acid = mutant_amino_acid.split('*')[0]
stop_codon_added = True
elif 'X' in mutant_amino_acid:
mutant_amino_acid = mutant_amino_acid.split('X')[0]
stop_codon_added = True
else:
stop_codon_added = False
if wildtype_amino_acid == '-':
Expand All @@ -126,9 +131,14 @@ def execute(self):
wildtype_amino_acid, mutant_amino_acid = line['amino_acid_change'].split('/')
if '*' in wildtype_amino_acid:
wildtype_amino_acid = wildtype_amino_acid.split('*')[0]
elif 'X' in wildtype_amino_acid:
wildtype_amino_acid = wildtype_amino_acid.split('X')[0]
if '*' in mutant_amino_acid:
mutant_amino_acid = mutant_amino_acid.split('*')[0]
stop_codon_added = True
elif 'X' in mutant_amino_acid:
mutant_amino_acid = mutant_amino_acid.split('X')[0]
stop_codon_added = True
else:
stop_codon_added = False
position = int(line['protein_position'].split('-', 1)[0]) - 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
chromosome_name start stop reference variant gene_name transcript_name amino_acid_change ensembl_gene_id wildtype_amino_acid_sequence downstream_amino_acid_sequence fusion_amino_acid_sequence variant_type protein_position transcript_expression gene_expression normal_depth normal_vaf tdna_depth tdna_vaf trna_depth trna_vaf index protein_length_change
12 96617457 96617460 CAGA C ELK3 ENST00000547249 AX/X ENSG00000111145 MESAITLWQFLLQLLLDQKHEHLICWTSNDGEFKLLKA inframe_del 38-39 NA NA NA NA NA NA NA NA 39805.ELK3.ENST00000547249.inframe_del.38-39AX/X
21 changes: 21 additions & 0 deletions tests/test_fasta_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,27 @@ def test_protein_change_with_asterisk_in_wildtype_and_mutant(self):
self.assertEqual(os.path.getsize(generate_fasta_output_file.name), 0)
self.assertEqual(os.path.getsize(generate_fasta_key_output_file.name), 0)

def test_protein_change_with_X_in_wildtype_and_mutatnt(self):
peptide_sequence_length = '21'
test_data_dir = os.path.join(self.test_data_dir, 'protein_change_with_X_in_wildtype_and_mutant')
generate_fasta_input_file = os.path.join(test_data_dir, 'input.tsv')
generate_fasta_output_file = tempfile.NamedTemporaryFile()
generate_fasta_key_output_file = tempfile.NamedTemporaryFile()

generate_fasta_params = {
'input_file' : generate_fasta_input_file,
'peptide_sequence_length' : self.peptide_sequence_length,
'epitope_length' : self.epitope_length,
'output_file' : generate_fasta_output_file.name,
'output_key_file' : generate_fasta_key_output_file.name,
'downstream_sequence_length': None,
}
generator = FastaGenerator(**generate_fasta_params)

self.assertFalse(generator.execute())
self.assertEqual(os.path.getsize(generate_fasta_output_file.name), 0)
self.assertEqual(os.path.getsize(generate_fasta_key_output_file.name), 0)

def test_protein_change_with_multiple_asterisks(self):
peptide_sequence_length = '21'
test_data_dir = os.path.join(self.test_data_dir, 'protein_change_with_multiple_asterisks')
Expand Down

0 comments on commit 964bb04

Please sign in to comment.