Skip to content

Commit

Permalink
dataset 1st2nd codons partitioned by each codon
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosp420 committed Aug 24, 2015
1 parent a838212 commit 6591671
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
11 changes: 10 additions & 1 deletion voseq/create_dataset/dataset.py
Expand Up @@ -436,7 +436,16 @@ def from_seq_objs_to_dataset(self):
if '1st' in self.codon_positions and '2nd' in self.codon_positions and \
'3rd' not in self.codon_positions and \
'ALL' not in self.codon_positions and \
'EACH' in self.partition_by_positions:
'EACH' in self.partition_by_positions and \
self.file_format == 'PHY':
self.partition_list = self.get_codons_in_one_partition(['1st', '2nd'])
return self.convert_lists_to_dataset(self.partition_list)

if '1st' in self.codon_positions and '2nd' in self.codon_positions and \
'3rd' not in self.codon_positions and \
'ALL' not in self.codon_positions and \
'EACH' in self.partition_by_positions and \
self.file_format != 'PHY':
self.partition_list = self.get_codons_in_each_partition(['1st', '2nd'])
return self.convert_lists_to_dataset(self.partition_list)

Expand Down
5 changes: 5 additions & 0 deletions voseq/create_dataset/phylip.py
Expand Up @@ -102,6 +102,11 @@ def make_charset_line(self, count_start, count_end, gene):
if len(self.codon_positions) == 1 and '3rd' in self.codon_positions:
line = 'DNA, {}_pos3 = {}-{}'.format(gene, count_start + 1, count_end)
return line
if len(self.codon_positions) == 2 and \
'1st' in self.codon_positions and \
'2nd' in self.codon_positions:
line = 'DNA, {}_pos12 = {}-{}'.format(gene, count_start + 1, count_end)
return line

def convert_lists_to_dataset(self, partitions):
"""
Expand Down
Expand Up @@ -380,6 +380,19 @@ def test_dataset_1st2nd_codon_partitioned_one(self):
expected = handle.read()
self.assertEqual(expected, result)

def test_dataset_1st2nd_codon_partitioned_each(self):
cleaned_data = self.cleaned_data.copy()
cleaned_data['partition_by_positions'] = 'EACH'
cleaned_data['positions'] = ['1st', '2nd']
dataset_creator = CreateDataset(cleaned_data)
result = dataset_creator.dataset_str

dataset_file = os.path.join(settings.BASE_DIR, '..', 'create_dataset',
'tests', 'create_phylip_dataset', 'dataset_1st2nd_codons.phy')
with open(dataset_file, "r") as handle:
expected = handle.read()
self.assertEqual(expected, result)

def test_charset_block_dataset_1st2nd_codon_partitioned_one(self):
cleaned_data = self.cleaned_data.copy()
cleaned_data['partition_by_positions'] = 'ONE'
Expand Down

0 comments on commit 6591671

Please sign in to comment.