-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from carlosp420/create_dataset
"Create dataset" tool
- Loading branch information
Showing
20 changed files
with
913 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from django import forms | ||
|
||
from public_interface.models import Genes | ||
from public_interface.models import GeneSets | ||
from public_interface.models import TaxonSets | ||
|
||
|
||
class BaseDatasetForm(forms.Form): | ||
taxonset = forms.ModelChoiceField( | ||
TaxonSets.objects.all(), | ||
label='Choose taxonset', | ||
required=False, | ||
empty_label='Choose taxonset', | ||
) | ||
geneset = forms.ModelChoiceField( | ||
GeneSets.objects.all(), | ||
label='Choose geneset', | ||
required=False, | ||
empty_label='Choose geneset', | ||
) | ||
gene_codes = forms.ModelMultipleChoiceField( | ||
Genes.objects.all(), | ||
label='Check to select your alignment/gene', | ||
required=False, | ||
widget=forms.CheckboxSelectMultiple(), | ||
) | ||
voucher_codes = forms.CharField( | ||
widget=forms.Textarea, | ||
label='... and/or a list of voucher codes', | ||
required=False, | ||
) | ||
|
||
def clean(self): | ||
"""Overwriting validator method of class form.""" | ||
cleaned_data = super(BaseDatasetForm, self).clean() | ||
taxonset = cleaned_data.get("taxonset") | ||
voucher_codes = cleaned_data.get("voucher_codes") | ||
|
||
geneset = cleaned_data.get("geneset") | ||
gene_codes = cleaned_data.get("gene_codes") | ||
print(gene_codes) | ||
|
||
if taxonset is None and voucher_codes.strip() == '': | ||
raise forms.ValidationError("You need to enter at least some " | ||
"voucher codes or select a taxonset.") | ||
|
||
if geneset is None and len(gene_codes) < 1: | ||
raise forms.ValidationError("You need to enter at least some " | ||
"gene codes or select a geneset.") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
from django import forms | ||
|
||
from core.forms import BaseDatasetForm | ||
|
||
|
||
class CreateDatasetForm(BaseDatasetForm): | ||
file_format = forms.ChoiceField( | ||
label='Choose file format', | ||
choices=[ | ||
('TNT', 'TNT format'), | ||
('NEXUS', 'NEXUS format'), | ||
('PHY', 'PHYLIP format'), | ||
('FASTA', 'Unaligned FASTA format'), | ||
], | ||
widget=forms.RadioSelect(), | ||
required=True, | ||
initial='FASTA', | ||
) | ||
|
||
outgroup = forms.CharField( | ||
label='Outgroup (code, for NEXUS and TNT)', | ||
help_text='Voucher code for using that specimen\'s sequence as ' | ||
'outgroup in NEXUS and TNT datasets.', | ||
required=False, | ||
) | ||
|
||
positions = forms.ChoiceField( | ||
label='Positions', | ||
help_text='codon positions', | ||
choices=[ | ||
('ALL', 'all'), | ||
('1st', '1st'), | ||
('2nd', '2nd'), | ||
('3rd', '3rd'), | ||
], | ||
widget=forms.RadioSelect(), | ||
initial='ALL', | ||
required=True, | ||
) | ||
|
||
partition_by_positions = forms.ChoiceField( | ||
label='Partition by positions', | ||
choices=[ | ||
('ONE', 'as one'), | ||
('EACH', 'each'), | ||
('1st-3rd', '1st-2nd, 3rd'), | ||
], | ||
widget=forms.RadioSelect(), | ||
initial='ONE', | ||
required=True, | ||
) | ||
|
||
translations = forms.BooleanField( | ||
label='Degen(erated)', | ||
widget=forms.CheckboxInput(), | ||
required=False, | ||
) | ||
|
||
aminoacids = forms.BooleanField( | ||
label='Amino acids', | ||
widget=forms.CheckboxInput(), | ||
required=False, | ||
) | ||
|
||
degen_translations = forms.ChoiceField( | ||
label='Degenerated translations)', | ||
choices=[ | ||
('NORMAL', 'normal'), | ||
('S', 'S'), | ||
('Z', 'Z'), | ||
('SZ', 'SZ'), | ||
], | ||
widget=forms.RadioSelect(), | ||
initial='NORMAL', | ||
required=True, | ||
) | ||
|
||
special = forms.BooleanField( | ||
label='Special', | ||
widget=forms.CheckboxInput(), | ||
required=False, | ||
) | ||
|
||
taxon_names = forms.MultipleChoiceField( | ||
label='What info do you want in the taxon names?', | ||
choices=[ | ||
('CODE', 'Code'), | ||
('ORDER', 'Order'), | ||
('FAMILY', 'Family'), | ||
('SUBFAMILY', 'Subfamily'), | ||
('TRIBE', 'Tribe'), | ||
('SUBTRIBE', 'Subtribe'), | ||
('GENUS', 'Genus'), | ||
('SPECIES', 'Species'), | ||
('SUBSPECIES', 'Subspecies'), | ||
('AUCTOR', 'Auctor'), | ||
('HOSTORG', 'Host org.'), | ||
('GENECODE', 'Gene code'), | ||
], | ||
widget=forms.CheckboxSelectMultiple(), | ||
initial=['CODE', 'GENUS', 'SPECIES'], | ||
required=False, | ||
help_text='If taxon_names is None, use standart code_genus_species', | ||
) | ||
|
||
exclude = forms.ChoiceField( | ||
help_text='If dataset is for single gene, exclude taxa missing this gene? ' | ||
'Otherwise include taxon with ? as sequences.', | ||
choices=[ | ||
('YES', 'yes'), | ||
('NO', 'no'), | ||
], | ||
widget=forms.RadioSelect(), | ||
initial='YES', | ||
required=True, | ||
) | ||
|
||
number_genes = forms.IntegerField( | ||
label='Minimum number of genes', | ||
required=False, | ||
) | ||
|
||
introns = forms.ChoiceField( | ||
choices=[ | ||
('YES', 'yes'), | ||
('NO', 'no'), | ||
], | ||
widget=forms.RadioSelect(), | ||
initial='YES', | ||
required=True, | ||
help_text='Ignore introns?', | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
Oops, something went wrong.