Skip to content

Commit

Permalink
Merge pull request #55 from carlosp420/create_dataset
Browse files Browse the repository at this point in the history
"Create dataset" tool
  • Loading branch information
carlosp420 committed Jan 29, 2015
2 parents 217ff91 + 5f41edc commit 79f8fd1
Show file tree
Hide file tree
Showing 20 changed files with 913 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
help:
@echo "serve - remove build artifacts"
@echo "serve - runserver for development"
@echo "test - use testing settings and SQlite3 database"

serve: index stats
Expand All @@ -16,7 +16,7 @@ import:
python voseq/manage.py migrate_db --dumpfile=test_db_dump.xml --settings=voseq.settings.local

index:
python voseq/manage.py rebuild_index
python voseq/manage.py rebuild_index --settings=voseq.settings.local

stats:
python voseq/manage.py create_stats --settings=voseq.settings.local
Expand Down
49 changes: 49 additions & 0 deletions voseq/core/forms.py
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.
3 changes: 3 additions & 0 deletions voseq/create_dataset/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
132 changes: 132 additions & 0 deletions voseq/create_dataset/forms.py
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.
3 changes: 3 additions & 0 deletions voseq/create_dataset/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
Loading

0 comments on commit 79f8fd1

Please sign in to comment.