Uid App¶
All stuff related with image The Unified Internal Database and site pages like index and about are defined in this module.
uid.models¶
Submission and user data¶
Inside model library, you can manage The Unified Internal Database objects.
The main object is uid.models.Submission which is the object that
a registered user create when starts creating a new submission. Animals and Samples
data loaded by user are manged by the uid.models.Animal and
uid.models.Sample class. The original name of such objects (defined
as Data source id from the IMAGE metadata rules) is managed by
uid.models.Animal and uid.models.Sample respectively
which track also the biosample_id of such objects and its Common statuses.
Here are presented the relations between uid.models.Submission objects:
Through relationship, you could rerieve all animal belonging to a submission, for example:
from uid.models import Submission, Animal
submission = Submission.objects.get(pk=1)
animals = Animal.objects.filter(submission=submission)
in this example animals is a django.db.models.query.QuerySet instance
with all animals defined in selected submission. You can also fecth all animals
from the submission instance itself:
animals = submission.animal_set
This command is equivalent of the previous.
Private data¶
Submission data (Animals, Samples) are considered private to the user when they are stored in
The Unified Internal Database. Each table (django.models.Model)
has an owner column in which a relation to django.contrib.auth.models.User
is defined. In such way, is possible to get all objects belonging to such user:
from uid.models import User
user = User.objects.get(username="test")
user_animals = Animal.objects.filter(owner=user)
django.contrib.auth.models.User are also contained in authenticated
sessions, and could be used in Views:
user_animals = Animal.objects.filter(owner=request.user)
The common.views.OwnerMixin extends the default get_queryset of
django.views.generic.detail.SingleObjectMixin in order to filter
QuerySet using self.request.user. Such Mixin can be inherited by all
django.views.generic.detail.SingleObjectMixin and
django.views.generic.list.MultipleObjectMixin derived classes in
order to filter objects relying on django authenticated sessions:
from django.views.generic import DetailView, ListView
from uid.models import Submission
from common.views import OwnerMixin
class DetailSubmissionView(OwnerMixin, DetailView):
model = Submission
template_name = "submissions/submission_detail.html"
class ListSubmissionsView(OwnerMixin, ListView):
model = Submission
template_name = "submissions/submission_list.html"
ordering = ['-created_at']
paginate_by = 10
since common.views.OwnerMixin inherits from
django.contrib.auth.mixins.LoginRequiredMixin, an authentication
sessions is required to access to derived views. The login redirect will be managed
if the session is anonymous
uid.models module contents¶
-
class
uid.models.Animal(*args, **kwargs)[source]¶ Bases:
uid.mixins.BioSampleMixin,uid.models.NameClass to model Animal (Organism). Inherits from
BioSampleMixin, related toNamethroughOneToOnerelationship to model Animal name (Data source id), and with the same relationship to modelmotherandfatherof such animal. In case that parents are unknown, could be linked with Unkwnon animals for cryoweb data or doens’t have relationship.Linked toDictBreeddictionary table to model info on species and breed. Linked toSampleto model Samples (Specimen from organims):from uid.models import Animal # get animal using primary key animal = Animal.objects.get(pk=1) # get animal name data_source_id = animal.name # get animal's parents mother = animal.mother father = animal.father # get breed and species info print(animal.breed.supplied_breed) print(animal.breed.specie.label) # get all samples (specimen) for this animals samples = animal.sample_set.all()
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.Confidence(*args, **kwargs)[source]¶ Bases:
uid.mixins.BaseMixin,django.db.models.base.ModelAbstract class which add confidence to models
-
class
uid.models.DictBase(*args, **kwargs)[source]¶ Bases:
uid.mixins.BaseMixin,django.db.models.base.ModelAbstract class to be inherited to all dictionary tables. It models fields like
label(the revised term like submitter or blood) andterm(the ontology id as the final part of the URI link)The fixed part of the URI could be customized from
Ontologyby settinglibrary_nameclass attribute accordingly:class DictRole(DictBase): library_name = 'EFO'
-
class
uid.models.DictBreed(*args, **kwargs)[source]¶ Bases:
uid.models.ConfidenceA class to deal with breed objects and their ontologies
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
format_attribute()[source]¶ Format mapped_breed attribute (with its ontology). Return None if no mapped_breed
-
property
mapped_breed¶ Alias for label attribute. Return general label if no term is found
-
property
mapped_breed_term¶ Alias for term attribute. Return general term if no term is found
-
exception
-
class
uid.models.DictCountry(*args, **kwargs)[source]¶ Bases:
uid.models.DictBase,uid.models.ConfidenceA class to model contries defined by NCI Thesaurus OBO Edition https://www.ebi.ac.uk/ols/ontologies/ncit
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.DictDevelStage(*args, **kwargs)[source]¶ Bases:
uid.models.DictBase,uid.models.ConfidenceA class to developmental stages defined as descendants of descendants of EFO_0000399
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.DictPhysioStage(*args, **kwargs)[source]¶ Bases:
uid.models.DictBase,uid.models.ConfidenceA class to physiological stages defined as descendants of descendants of PATO_0000261
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.DictRole(*args, **kwargs)[source]¶ Bases:
uid.models.DictBaseA class to model roles defined as childs of http://www.ebi.ac.uk/efo/EFO_0002012
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.DictSex(*args, **kwargs)[source]¶ Bases:
uid.models.DictBaseA class to model sex as defined in PATO
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.DictSpecie(*args, **kwargs)[source]¶ Bases:
uid.models.DictBase,uid.models.ConfidenceA class to model species defined by NCBI organismal classification http://www.ebi.ac.uk/ols/ontologies/ncbitaxon
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.DictUberon(*args, **kwargs)[source]¶ Bases:
uid.models.DictBase,uid.models.ConfidenceA class to model anatomies modeled in uberon
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.Name(*args, **kwargs)[source]¶ Bases:
uid.mixins.BaseMixin,django.db.models.base.ModelModel UID names: define a name (sample or animal) unique for each data submission
-
property
validationresult¶ return the first validationresult object (should be uinique)
-
property
-
class
uid.models.Ontology(id, library_name, library_uri, comment)[source]¶ Bases:
uid.mixins.BaseMixin,django.db.models.base.Model-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.Organization(id, name, address, country, URI, role)[source]¶ Bases:
uid.mixins.BaseMixin,django.db.models.base.Model-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.Person(id, user, initials, affiliation, role)[source]¶ Bases:
uid.mixins.BaseMixin,django.db.models.base.Model-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.Publication(id, doi)[source]¶ Bases:
uid.mixins.BaseMixin,django.db.models.base.Model-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.Sample(id, name, submission, biosample_id, owner, status, last_changed, last_submitted, publication, alternative_id, description, material, animal, protocol, collection_date, collection_place_latitude, collection_place_longitude, collection_place, collection_place_accuracy, organism_part, developmental_stage, physiological_stage, animal_age_at_collection, animal_age_at_collection_units, availability, storage, storage_processing, preparation_interval, preparation_interval_units)[source]¶ Bases:
uid.mixins.BioSampleMixin,uid.models.Name-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
-
class
uid.models.Submission(id, title, project, description, gene_bank_name, gene_bank_country, datasource_type, datasource_version, organization, uploaded_file, created_at, updated_at, status, message, owner)[source]¶ Bases:
uid.mixins.BaseMixin,django.db.models.base.Model-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
exception
uid.mixins¶
uid.mixins module contents¶
Created on Fri Jun 28 14:46:39 2019
@author: Paolo Cozzi <cozzi@ibba.cnr.it>
Define mixins classes for uid.models
-
class
uid.mixins.BaseMixin[source]¶ Bases:
objectBase class for UID tables. It implement common stuff for all UID tables:
from uid.models import BaseMixin class Submission(BaseMixin): pass
-
class
uid.mixins.BioSampleMixin[source]¶ Bases:
uid.mixins.BaseMixinCommon methods for animal and samples useful in biosample generation Need to called with data into biosample or animals:
from uid.models import Animal animal = Animal.objects.get(pk=1) biosample_data = animal.to_biosample()
-
can_delete()[source]¶ Returns True if I can delete a sample/animal according to submission status
- Returns
bool
-
can_edit()[source]¶ Returns True if I can edit a sample/animal according to submission status
- Returns
bool
-
property
data_source_id¶ Get Data source id (original animal/sample name)
-
property
gene_bank_country¶ Return
DictCountryrelationship from relatedSubmissionobject
-
property
gene_bank_name¶ Return gene bank name from related
Submissionobject
-
get_attributes()[source]¶ Common attribute definition required from Animal and samples. Need to be called inside Animal/sample get_atribute method. Keys is the name in metadata rules
- Returns
a dictionary object
- Return type
-
property
organization¶ Return
Organizationrelationship from relatedSubmissionobject
-
property
person¶ Retrieve
Personinformation from owner relationship
-
property
specie¶
-
uid.views¶
uid.views module contents¶
Created on Tue Feb 6 15:04:07 2018
@author: Paolo Cozzi <paolo.cozzi@ptp.it>
-
class
uid.views.AboutSubmissionView(**kwargs)[source]¶ Bases:
django.views.generic.base.TemplateView-
template_name= 'uid/about_submission.html'¶
-
-
class
uid.views.AboutUploadingView(**kwargs)[source]¶ Bases:
django.views.generic.base.TemplateView-
template_name= 'uid/uploading_data.html'¶
-
-
class
uid.views.AboutView(**kwargs)[source]¶ Bases:
django.views.generic.base.TemplateView-
template_name= 'uid/about.html'¶
-
-
class
uid.views.DashBoardView(**kwargs)[source]¶ Bases:
django.contrib.auth.mixins.LoginRequiredMixin,django.views.generic.base.TemplateView-
template_name= 'uid/dashboard.html'¶
-
-
class
uid.views.IndexView(**kwargs)[source]¶ Bases:
django.views.generic.base.TemplateView-
template_name= 'uid/index.html'¶
-
-
class
uid.views.PrivacyView(**kwargs)[source]¶ Bases:
django.views.generic.base.TemplateView-
template_name= 'uid/privacy_policy.html'¶
-
-
class
uid.views.SummaryView(**kwargs)[source]¶ Bases:
django.contrib.auth.mixins.LoginRequiredMixin,django.views.generic.base.TemplateView-
template_name= 'uid/summary.html'¶
-
-
class
uid.views.TermsView(**kwargs)[source]¶ Bases:
django.views.generic.base.TemplateView-
template_name= 'uid/terms_and_conditions.html'¶
-
-
class
uid.views.UpdateOrganizationView(**kwargs)[source]¶ Bases:
common.views.FormInvalidMixin,django.contrib.auth.mixins.LoginRequiredMixin,django.views.generic.edit.UpdateView-
form_class¶ alias of
uid.forms.OrganizationForm
-
model¶ alias of
uid.models.Organization
-
success_url¶
-
template_name= 'uid/organization_form.html'¶
-