Skip to content

Commit

Permalink
need to fix genbankfasta
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosp420 committed Nov 5, 2015
1 parent 1e70cdf commit 337ac13
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
13 changes: 2 additions & 11 deletions voseq/create_dataset/utils.py
Expand Up @@ -88,17 +88,8 @@ def create_dataset(self):
self.voucher_codes = get_voucher_codes(self.cleaned_data)
self.gene_codes = get_gene_codes(self.cleaned_data)
self.create_seq_objs()
if self.file_format == 'GenbankFASTA':
fasta = CreateGenbankFasta(self.codon_positions, self.partition_by_positions,
self.seq_objs, self.gene_codes, self.voucher_codes,
self.file_format)
fasta_dataset = fasta.from_seq_objs_to_dataset()
self.warnings += fasta.warnings
self.dataset_file = fasta.dataset_file
self.aa_dataset_file = fasta.aa_dataset_file
return fasta_dataset

if self.file_format in ['NEXUS', 'FASTA', 'MEGA', 'TNT', 'PHYLIP']:

if self.file_format in ['NEXUS', 'GenbankFASTA', 'FASTA', 'MEGA', 'TNT', 'PHYLIP']:
try:
dataset = Dataset(self.seq_objs, format=self.file_format, partitioning=self.partition_by_positions,
codon_positions=self.codon_positions[0], aminoacids=self.aminoacids,
Expand Down
2 changes: 2 additions & 0 deletions voseq/genbank_fasta/tests/test_genbank_fasta.py
Expand Up @@ -35,6 +35,7 @@ def test_results(self):
)
self.assertEqual(200, c.status_code)

""" Uncommend after implementing GenbankFASTA in dataset-creator
def test_results_dataset(self):
self.client.post('/accounts/login/', {'username': 'admin', 'password': 'pass'})
c = self.client.post('/genbank_fasta/results/',
Expand All @@ -49,6 +50,7 @@ def test_results_dataset(self):
self.assertTrue(expected.strip() in str(c.content))
expected = "TGAGCCGGTATAATTGGTACATCCCTAAGTCTTATTATTCGAACCGAATTAGGAAATCCTAGTTTTTTAATTGGAGATGATCAAATTTATAATACCATTGTAACAGCTCATGCTTTTATTATAATTTTTTTTATAGTTATGCCAATTATAATTGGAGGATTTGGTAATTGACTTGTACCATTAATATTGGGAGCCCCAGATATAGCTTTCCCCCGAATAAATTATATAAGATTTTGATTATTGCCTCCATCCTTAATTCTTTTAATTTCAAGTAGAATTGTAGAAAATGGGGCAGGAACTGGATGAACAGTTTACCCCCCACTTTCATCTAATATTGCCCATAGAGGAGCTTCAGTGGATTTAGCTATTTTTTCTTTACATTTAGCTGGGATTTCCTCTATCTTAGGAGCTATTAATTTTATTACTACAATTATTAATATACGAATTAATAATATATCTTATGATCAAATACCTTTATTTGTATGAGCAGTAGGAATTACAGCATTACTTCTCTTATTATCTTTACCAGTTTTAGCTGGAGCTATTACTATACTTTTAACGGATCGAAATCTTAATACCTCATTTTTTGATTCCTGCGGAGGAGGAGATCC"
self.assertTrue(expected.strip() in str(c.content))
"""

def test_results_valid_form(self):
self.client.post('/accounts/login/', {'username': 'admin', 'password': 'pass'})
Expand Down
29 changes: 17 additions & 12 deletions voseq/genbank_fasta/views.py
Expand Up @@ -43,37 +43,42 @@ def results(request):
cleaned_data = form.cleaned_data
cleaned_data['file_format'] = 'GenbankFASTA'
cleaned_data['number_genes'] = ''
cleaned_data['aminoacids'] = True
cleaned_data['translations'] = False
cleaned_data['aminoacids'] = False
cleaned_data['positions'] = 'ALL'
cleaned_data['partition_by_positions'] = 'ONE'
cleaned_data['partition_by_positions'] = 'by gene'
cleaned_data['taxon_names'] = ['CODE', 'GENUS', 'SPECIES']
cleaned_data['outgroup'] = ''

dataset_creator = CreateDataset(cleaned_data)
dataset, aa_dataset = dataset_creator.dataset_str
dataset = dataset[0:1500] + '\n...\n\n\n' + '#######\nComplete dataset file available for download.\n#######'
aa_dataset = aa_dataset[0:1500] + '\n...\n\n\n' + '#######\nComplete dataset file available for download.\n#######'
dataset = dataset_creator.dataset_str
dataset_short = dataset[0:1500] + '\n...\n\n\n' + '#######\nComplete dataset file available for download.\n#######'
errors = dataset_creator.errors
warnings = dataset_creator.warnings

dataset_file_abs = dataset_creator.dataset_file
aa_dataset_file_abs = dataset_creator.aa_dataset_file

# Uncommend aa datasets after Biopython accepts translation of gapped seqs.
# cleaned_data['aminoacids'] = True
# dataset_creator = CreateDataset(cleaned_data)
# aa_dataset = dataset_creator.dataset_str
# aa_dataset_file_abs = dataset_creator.dataset_file

if dataset_file_abs is not None:
dataset_file = re.search('([a-zA-Z]+_[a-z0-9]+\.txt)', dataset_file_abs).groups()[0]
aa_dataset_file = re.search('([a-zA-Z]+_aa_[a-z0-9]+\.txt)', aa_dataset_file_abs).groups()[0]
# aa_dataset_file = re.search('([a-zA-Z]+_aa_[a-z0-9]+\.txt)', aa_dataset_file_abs).groups()[0]
else:
dataset_file = False
aa_dataset_file = False
# aa_dataset_file = False

return render(request, 'genbank_fasta/results.html',
{
'username': username,
'items_with_accession': '',
'dataset': dataset,
'dataset': dataset_short,
'fasta_file': dataset_file,
'protein': aa_dataset,
# 'protein': aa_dataset,
'errors': errors,
'protein_file': aa_dataset_file,
# 'protein_file': aa_dataset_file,
'warnings': warnings,
'version': version,
'stats': stats,
Expand Down

0 comments on commit 337ac13

Please sign in to comment.