Skip to content

Commit

Permalink
Merge pull request #62 from carlosp420/dataset_form_inheritance
Browse files Browse the repository at this point in the history
Dataset form inheritance, docs and setup.py
  • Loading branch information
carlosp420 committed Jan 31, 2015
2 parents 0f809bc + 39c2313 commit 8a1d93d
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 50 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Expand Up @@ -9,6 +9,12 @@ config.json
*bak
*.fasta

# package builds
VoSeq.egg-info
build
dist
voseq.egg-info

# coverage
.coverage
voseq/htmlcov
Expand Down
3 changes: 2 additions & 1 deletion AUTHORS.rst
Expand Up @@ -6,7 +6,8 @@ Development Lead
----------------

* Carlos Peña <mycalesis@gmail.com>
* Victor Solis <<vm_solism@yahoo.es>
* Tobias Malm <tobemalm@gmail.com>
* Victor Solis <vm_solism@yahoo.es>

Contributors
------------
Expand Down
1 change: 1 addition & 0 deletions requirements/base.txt
@@ -1 +1,2 @@
Django==1.7.3
biopython==1.65
2 changes: 1 addition & 1 deletion requirements/testing.txt
Expand Up @@ -10,5 +10,5 @@ django-haystack==2.3.1
elasticsearch==1.2.0
coveralls==0.5
django-debug-toolbar==1.2.2
biopython==1.65
pytz==2014.10
Sphinx==1.2.3
25 changes: 25 additions & 0 deletions setup.py
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
try:
from setuptools import setup
except ImportError:
from distutils.core import setup

import voseq

version = voseq.__version__

setup(
name='VoSeq',
version=version,
author='Carlos Pena, Tobias Malm, Victor Mezarino',
author_email='carlosp420@gmail.com',
packages=[
'voseq',
],
include_package_data=True,
install_requires=[
'Django==1.7.3',
],
zip_safe=False,
scripts=['voseq/manage.py'],
)
18 changes: 17 additions & 1 deletion voseq/core/forms.py
Expand Up @@ -6,6 +6,14 @@


class BaseDatasetForm(forms.Form):
"""Base class for datasets.
* Handles list of voucher codes including those from taxonsets.
* Handles list of gene codes including those from genesets.
Other dataset classes should inherit from this one.
"""
taxonset = forms.ModelChoiceField(
TaxonSets.objects.all(),
label='Choose taxonset',
Expand All @@ -31,7 +39,15 @@ class BaseDatasetForm(forms.Form):
)

def clean(self):
"""Overwriting validator method of class form."""
"""Overwriting validator method of class form.
Drops vouchers if their codes have been flagged by users with two
consecutive dashes ``--``.
Returns:
Sets of voucher and genes codes.
"""
cleaned_data = super(BaseDatasetForm, self).clean()
taxonset = cleaned_data.get("taxonset")
voucher_codes = cleaned_data.get("voucher_codes")
Expand Down
51 changes: 4 additions & 47 deletions voseq/genbank_fasta/forms.py
@@ -1,49 +1,6 @@
from django import forms
from core.forms import BaseDatasetForm

from public_interface.models import Genes
from public_interface.models import GeneSets
from public_interface.models import TaxonSets


class GenBankFastaForm(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(GenBankFastaForm, 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.")
class GenBankFastaForm(BaseDatasetForm):
"""The methods needed by this class are very basic."""
pass

0 comments on commit 8a1d93d

Please sign in to comment.