Skip to content

Commit

Permalink
fasta as aminoacids
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosp420 committed Aug 5, 2015
1 parent 29fc9da commit e56c576
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions voseq/create_dataset/dataset.py
Expand Up @@ -202,11 +202,20 @@ def convert_lists_to_dataset(self, partitions):
else:
line_contents = line.split('\n')
taxon = line_contents[0]
voucher_code = taxon.replace('>', '').split('_')[0]
sequence = line_contents[1]

if self.aminoacids is not True and this_gene != '' and \
self.translations is True:
sequence = self.degenerate(sequence, this_gene)

if self.aminoacids is True:
sequence = self.translate_this_sequence(
sequence,
this_gene,
voucher_code,
)

out += '\n'
out += '\n'.join([taxon, sequence])

Expand Down
24 changes: 24 additions & 0 deletions voseq/create_dataset/tests/tests_create_fasta_dataset.py
Expand Up @@ -110,3 +110,27 @@ def test_create_dataset_degenerated_warning_data_cannot_be_of_partial_codons(sel
)
expected = 'Cannot degenerate codons if they you have not selected all codon positions'
self.assertTrue(expected in str(c.content))

def test_fasta_as_aminoacids(self):
self.c.post('/accounts/login/', {'username': 'admin', 'password': 'pass'})
c = self.c.post('/create_dataset/results/',
{
'voucher_codes': 'CP100-10',
'gene_codes': 3, # wingless
'geneset': '',
'taxonset': '',
'translations': True,
'introns': 'YES',
'file_format': 'FASTA',
'degen_translations': 'NORMAL',
'exclude': 'YES',
'aminoacids': True,
'special': False,
'outgroup': '',
'positions': 'ALL',
'partition_by_positions': 'ONE',
'taxon_names': ['CODE', 'GENUS', 'SPECIES'],
}
)
expected = 'GKSTTTGHLIYKCGGIDKRTIEKFEKEAQEM'
self.assertTrue(expected in str(c.content))
2 changes: 1 addition & 1 deletion voseq/create_dataset/utils.py
Expand Up @@ -86,7 +86,7 @@ def create_dataset(self):
fasta = CreateFasta(self.codon_positions, self.partition_by_positions,
self.seq_objs, self.gene_codes, self.voucher_codes,
self.file_format, degen_translations=self.degen_translations,
translations=self.translations)
translations=self.translations, aminoacids=self.aminoacids)
fasta_dataset = fasta.from_seq_objs_to_dataset()
self.warnings += fasta.warnings
self.dataset_file = fasta.dataset_file
Expand Down

0 comments on commit e56c576

Please sign in to comment.