Skip to content

Commit

Permalink
producing FASTA dataset based on requestd codon positions
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosp420 committed Feb 4, 2015
1 parent 845efb1 commit 5ecc010
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions voseq/create_dataset/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CreateDatasetForm(BaseDatasetForm):
)

positions = forms.MultipleChoiceField(
label='Positions',
label='Codon Positions',
help_text='Codon positions to keep and write into datasets',
choices=[
('ALL', 'all'),
Expand All @@ -34,7 +34,7 @@ class CreateDatasetForm(BaseDatasetForm):
('3rd', '3rd'),
],
widget=forms.CheckboxSelectMultiple(),
initial='ALL',
initial=['ALL'],
required=True,
)

Expand Down
3 changes: 3 additions & 0 deletions voseq/create_dataset/templates/create_dataset/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ <h3 class="panel-title"><b>Enter the required info to make yourself a ready-to-r
Amino Acids->Special->Degen->All->1st—2nd,3rd):
</td>
<td>
{% for error in form.positions.errors %}
<p class="text-danger">{{ error }}</p>
{% endfor %}
<b>{{ form.positions.label }}</b>
{{ form.positions }}

Expand Down
9 changes: 5 additions & 4 deletions voseq/create_dataset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def __init__(self, cleaned_data):
print(">>>>>>_init", cleaned_data)
self.errors = []
self.seq_objs = dict()
self.codon_positions = cleaned_data['positions']
self.cleaned_data = cleaned_data
self.voucher_codes = get_voucher_codes(cleaned_data)
self.gene_codes = get_gene_codes(cleaned_data)
self.reading_frames = self.get_reading_frames()
self.taxon_names = cleaned_data['taxon_names']
self.dataset_str = self.create_dataset()
self.codon_positions = cleaned_data['positions']
self.reading_frames = self.get_reading_frames()

def create_dataset(self):
self.voucher_codes = get_voucher_codes(self.cleaned_data)
Expand Down Expand Up @@ -86,7 +86,8 @@ def from_seq_objs_to_fasta(self):
this_gene = seq_record.name
seq_str = '>' + this_gene + '\n' + '--------------------'
append(seq_str)
seq_str = '>' + seq_record.id + '\n' + str(seq_record.seq)
seq_record_seq_str = str(self.get_sequence_based_on_codon_positions(this_gene, seq_record.seq))
seq_str = '>' + seq_record.id + '\n' + seq_record_seq_str
append(seq_str)

return '\n'.join(fasta_str)
Expand Down Expand Up @@ -137,7 +138,7 @@ def get_sequence_based_on_codon_positions(self, gene_code, seq):
:param gene_code: as lower case
:param seq: as BioPython seq object.
:return: sequence as string with codon positions removed, if needed.
:return: sequence as Seq object with codon positions requested by user.
Example:
If reading frame is 2: ATGGGG becomes TGGGG. Then the sequence is
Expand Down

0 comments on commit 5ecc010

Please sign in to comment.