コード例 #1
0
ファイル: models.py プロジェクト: DISBi/django-disbi
class Metabolite(BiologicalModel):
    name = dmodels.CharField(max_length=512,
                             di_display_name='metabolite_name',
                             di_show=True)
    derivative_group = dmodels.ForeignKey('DerivativeGroup',
                                          null=True,
                                          blank=True)
    co_a_derivative = dmodels.ForeignKey('CoADerivative',
                                         null=True,
                                         blank=True)

    def __str__(self):
        return self.name
コード例 #2
0
ファイル: models.py プロジェクト: DISBi/django-disbi
class GCMSData(ExperimentalData):
    derivative_group = dmodels.ForeignKey('DerivativeGroup',
                                          on_delete=models.CASCADE)

    class Meta:
        unique_together = (('derivative_group', 'experiment'), )
        verbose_name_plural = 'Metabolome GCMS data'

    def __str__(self):
        return 'Metabolome GCMS datapoint'
コード例 #3
0
ファイル: models.py プロジェクト: DISBi/django-disbi
class CoAData(ExperimentalData):
    co_a_derivative = dmodels.ForeignKey('CoADerivative',
                                         on_delete=models.PROTECT)
    stderr = dmodels.FloatField(null=True, blank=True, di_show=True)

    class Meta:
        unique_together = (('co_a_derivative', 'experiment'), )
        verbose_name_plural = 'CoA data'

    def __str__(self):
        return 'CoA datapoint'
コード例 #4
0
ファイル: models.py プロジェクト: DISBi/django-disbi
class ProteomeData(MeasurementModel):
    locus = dmodels.ForeignKey('Locus', on_delete=models.PROTECT)
    fold_change = dmodels.FloatField(di_show=True)
    adjusted_p_value = dmodels.FloatField(di_show=True,
                                          validators=[validate_probabilty])
    unique_peptides = dmodels.IntegerField()

    class Meta:
        unique_together = (('locus', 'experiment'), )
        verbose_name_plural = 'Proteom data'

    def __str__(self):
        return 'Proteome Datapoint'
コード例 #5
0
ファイル: models.py プロジェクト: DISBi/django-disbi
class TranscriptomeData(MeasurementModel):
    locus = dmodels.ForeignKey('Locus', on_delete=models.PROTECT)

    class Meta:
        abstract = True
        unique_together = (('locus', 'experiment'), )

    def __str__(self):
        try:
            return '{}: {:10.2f}'.format(self.transcript.transcript_identifier,
                                         self.mean_rpkm)
        except:
            return '{}'.format(self.mean_rpkm)
コード例 #6
0
ファイル: models.py プロジェクト: DISBi/django-disbi
class FluxData(MeasurementModel):
    flux = dmodels.FloatField(di_show=True, validators=[validate_flux])
    flux_min = dmodels.FloatField(di_show=True,
                                  di_display_name='lb',
                                  validators=[validate_flux])
    flux_max = dmodels.FloatField(di_show=True,
                                  di_display_name='ub',
                                  validators=[validate_flux])

    reaction = dmodels.ForeignKey('Reaction', on_delete=models.CASCADE)

    class Meta:
        unique_together = ((
            'reaction',
            'experiment',
        ))
        verbose_name_plural = 'Fluxes'

    def __str__(self):
        return 'Flux datapoint'
コード例 #7
0
ファイル: models.py プロジェクト: DISBi/django-disbi
class Experiment(models.Model, DisbiExperiment):
    EXPERIMENT_TYPE_CHOICES = (
        ('transcriptome', 'Transcriptome'),
        ('proteome', 'Proteome'),
        ('metabolome', 'Metabolome'),
        ('flux', 'Predicted Flux'),
    )
    experiment_type = dmodels.CharField(max_length=45,
                                        choices=EXPERIMENT_TYPE_CHOICES,
                                        di_choose=True)
    # The first name is the DB name, the second is human readable.
    EXPERIMENT_METHOD_CHOICES = (
        ('Transcriptome', (('rnaseq', 'RNAseq'), )),
        ('Proteome', (('shotgun', 'shotgun'), )),
        ('Metabolome', (
            ('gcms', 'GCMS'),
            ('coa', 'CoA-method'),
        )),
        ('Predicted Flux', (('fba', 'FBA'), )),
    )
    experiment_method = dmodels.CharField(max_length=45,
                                          choices=EXPERIMENT_METHOD_CHOICES,
                                          di_choose=True)
    c_source = dmodels.CharField(max_length=45,
                                 blank=True,
                                 verbose_name='Carbon source',
                                 di_choose=True,
                                 di_show=True,
                                 di_combinable=True)
    place = dmodels.CharField(max_length=45)
    group = dmodels.CharField(max_length=45)
    raw_data = dmodels.ForeignKey(
        'RawData', help_text='A file with the raw data for the experiment')
    notes = dmodels.TextField(blank=True, default='')

    class Meta:
        unique_together = (('experiment_type', 'experiment_method', 'c_source',
                            'group', 'raw_data'), )

    def __str__(self):
        return '{}. {}: {}'.format(
            self.id,
            self.get_experiment_type_display(),
            self.get_experiment_method_display(),
        )

    def clean(self):
        """
        Check whether the experiment method matches the experiment type.
        """
        opt_groups = get_optgroups(self.EXPERIMENT_METHOD_CHOICES)
        hr_experiment_type = get_hr_val(self.EXPERIMENT_TYPE_CHOICES,
                                        self.experiment_type)
        if self.experiment_method not in opt_groups[hr_experiment_type]:
            hr_experiment_method = get_hr_val(
                remove_optgroups(self.EXPERIMENT_METHOD_CHOICES),
                self.experiment_method)
            raise ValidationError(
                _('{type} does not belong to the method {method}.'.format(
                    type=hr_experiment_type, method=hr_experiment_method)))

    def c_source_display(self):
        return self.c_source if self.c_source else '-'

    c_source_display.short_description = 'Carbon source'
コード例 #8
0
class MeasurementModel(models.Model):
    """Base class for clustering the measurement models."""
    experiment = dmodels.ForeignKey('Experiment', on_delete=models.CASCADE)
    
    class Meta:
        abstract = True