コード例 #1
0
class OutcomeSchema(BaseSchema):

    participant_id = field_for(Outcome,
                               'participant_id',
                               required=True,
                               load_only=True,
                               example='PT_DZB048J5')
    age_at_event_days = field_for(Outcome,
                                  'age_at_event_days',
                                  validate=validate_age,
                                  example=232)
    vital_status = field_for(
        Outcome,
        'vital_status',
        validate=enum_validation_generator(VITAL_STATUS_ENUM))

    disease_related = field_for(
        Outcome,
        'disease_related',
        validate=enum_validation_generator(DISEASE_RELATED_ENUM))

    class Meta(BaseSchema.Meta):
        model = Outcome
        resource_url = 'api.outcomes'
        collection_url = 'api.outcomes_list'

    _links = ma.Hyperlinks({
        'self':
        ma.URLFor(Meta.resource_url, kf_id='<kf_id>'),
        'collection':
        ma.URLFor(Meta.collection_url),
        'participant':
        ma.URLFor('api.participants', kf_id='<participant_id>')
    })
コード例 #2
0
class GenomicFileSchema(BaseSchema, IndexdFileSchema):
    class Meta(BaseSchema.Meta, IndexdFileSchema.Meta):
        model = GenomicFile
        resource_url = 'api.genomic_files'
        collection_url = 'api.genomic_files_list'

        exclude = (BaseSchema.Meta.exclude + (
            'biospecimen',
            'sequencing_experiment',
        ) + (
            'task_genomic_files',
            'biospecimen_genomic_files',
        ) + ('sequencing_experiment_genomic_files',
             'read_group_genomic_files'))

    paired_end = field_for(GenomicFile,
                           'paired_end',
                           validate=enum_validation_generator(PAIRED_END_ENUM))

    data_type = field_for(GenomicFile,
                          'data_type',
                          validate=enum_validation_generator(DATA_TYPE_ENUM))
    availability = field_for(
        GenomicFile,
        'availability',
        validate=enum_validation_generator(AVAILABILITY_ENUM))

    latest_did = field_for(GenomicFile,
                           'latest_did',
                           required=False,
                           dump_only=True)

    _links = ma.Hyperlinks(
        {
            'self':
            ma.URLFor(Meta.resource_url, kf_id='<kf_id>'),
            'collection':
            ma.URLFor(Meta.collection_url),
            'task_genomic_files':
            ma.URLFor('api.task_genomic_files_list',
                      genomic_file_id='<kf_id>'),
            'biospecimen_genomic_files':
            ma.URLFor('api.biospecimen_genomic_files_list',
                      genomic_file_id='<kf_id>'),
            'read_group_genomic_files':
            ma.URLFor('api.read_group_genomic_files_list',
                      genomic_file_id='<kf_id>'),
            'sequencing_experiment_genomic_files':
            ma.URLFor('api.sequencing_experiment_genomic_files_list',
                      genomic_file_id='<kf_id>'),
            'read_groups':
            ma.URLFor('api.read_groups_list', genomic_file_id='<kf_id>'),
            'sequencing_experiments':
            ma.URLFor('api.sequencing_experiments_list',
                      genomic_file_id='<kf_id>'),
            'biospecimens':
            ma.URLFor('api.biospecimens_list', genomic_file_id='<kf_id>')
        },
        description='Resource links and pagination')
コード例 #3
0
class DiagnosisSchema(BaseSchema):
    participant_id = field_for(Diagnosis,
                               'participant_id',
                               required=True,
                               load_only=True,
                               example='PT_DZB048J5')
    age_at_event_days = field_for(Diagnosis,
                                  'age_at_event_days',
                                  validate=validate_age,
                                  example=232)
    diagnosis_category = field_for(
        Diagnosis,
        'diagnosis_category',
        validate=enum_validation_generator(DIAGNOSIS_CATEGORY_ENUM))

    class Meta(BaseSchema.Meta):
        model = Diagnosis
        resource_url = 'api.diagnoses'
        collection_url = 'api.diagnoses_list'

    _links = ma.Hyperlinks({
        'self':
        ma.URLFor(Meta.resource_url, kf_id='<kf_id>'),
        'collection':
        ma.URLFor(Meta.collection_url),
        'participant':
        ma.URLFor('api.participants', kf_id='<participant_id>'),
        'biospecimen_diagnoses':
        ma.URLFor('api.biospecimen_diagnoses_list', diagnosis_id='<kf_id>'),
        'biospecimens':
        ma.URLFor('api.biospecimens_list', diagnosis_id='<kf_id>')
    })
コード例 #4
0
class StudyFileSchema(BaseSchema, IndexdFileSchema):
    availability = field_for(
        StudyFile,
        'availability',
        validate=enum_validation_generator(AVAILABILITY_ENUM))

    class Meta(BaseSchema.Meta):
        model = StudyFile
        resource_url = 'api.study_files'
        collection_url = 'api.study_files_list'

    study_id = field_for(StudyFile, 'study_id', required=True, load_only=True)

    latest_did = field_for(StudyFile,
                           'latest_did',
                           required=False,
                           dump_only=True)

    _links = ma.Hyperlinks({
        'self':
        ma.URLFor(Meta.resource_url, kf_id='<kf_id>'),
        'collection':
        ma.URLFor(Meta.collection_url),
        'study':
        ma.URLFor('api.studies', kf_id='<study_id>')
    })
コード例 #5
0
class ParticipantSchema(BaseSchema):
    study_id = field_for(Participant, 'study_id', required=True,
                         load_only=True)
    family_id = field_for(Participant, 'family_id',
                          load_only=True,
                          required=False, example='FM_ABB2C104')
    gender = field_for(Participant, 'gender',
                       validate=enum_validation_generator(
                           GENDER_ENUM))
    ethnicity = field_for(Participant, 'ethnicity',
                          validate=enum_validation_generator(
                              ETHNICITY_ENUM))
    race = field_for(Participant, 'race',
                     validate=enum_validation_generator(
                         RACE_ENUM))
    diagnosis_category = field_for(Participant, 'diagnosis_category',
                                   validate=enum_validation_generator(
                                       DIAGNOSIS_CATEGORY_ENUM))
    species = field_for(Participant, 'species',
                        validate=enum_validation_generator(
                            SPECIES_ENUM))

    class Meta(BaseSchema.Meta):
        model = Participant
        resource_url = 'api.participants'
        collection_url = 'api.participants_list'
        exclude = (BaseSchema.Meta.exclude +
                   ('study', 'family') +
                   ('diagnoses', 'phenotypes', 'outcomes', 'biospecimens'))

    _links = ma.Hyperlinks({
        'self': ma.URLFor(Meta.resource_url, kf_id='<kf_id>'),
        'collection': ma.URLFor(Meta.collection_url),
        'study': ma.URLFor('api.studies', kf_id='<study_id>'),
        'family': PatchedURLFor('api.families', kf_id='<family_id>'),
        'diagnoses': ma.URLFor('api.diagnoses_list', participant_id='<kf_id>'),
        'phenotypes': ma.URLFor('api.phenotypes_list',
                                participant_id='<kf_id>'),
        'outcomes': ma.URLFor('api.outcomes_list',
                              participant_id='<kf_id>'),
        'biospecimens': ma.URLFor('api.biospecimens_list',
                                  participant_id='<kf_id>'),
        'family_relationships': ma.URLFor('api.family_relationships_list',
                                          participant_id='<kf_id>')
    })
コード例 #6
0
class FamilySchema(BaseSchema):
    family_type = field_for(
        Family,
        'family_type',
        validate=enum_validation_generator(FAMILY_TYPE_ENUM))

    class Meta(BaseSchema.Meta):
        model = Family
        resource_url = 'api.families'
        collection_url = 'api.families_list'
        exclude = BaseSchema.Meta.exclude + ('participants', )

    _links = ma.Hyperlinks({
        'self':
        ma.URLFor(Meta.resource_url, kf_id='<kf_id>'),
        'collection':
        ma.URLFor(Meta.collection_url),
        'participants':
        ma.URLFor('api.participants_list', family_id='<kf_id>')
    })
コード例 #7
0
class PhenotypeSchema(BaseSchema):

    participant_id = field_for(Phenotype, 'participant_id', required=True,
                               load_only=True, example='PT_DZB048J5')
    age_at_event_days = field_for(Phenotype, 'age_at_event_days',
                                  validate=validate_age, example=232)
    observed = field_for(Phenotype, 'observed',
                         validate=enum_validation_generator(
                             OBSERVED_ENUM))

    class Meta(BaseSchema.Meta):
        model = Phenotype
        resource_url = 'api.phenotypes'
        collection_url = 'api.phenotypes_list'

    _links = ma.Hyperlinks({
        'self': ma.URLFor(Meta.resource_url, kf_id='<kf_id>'),
        'collection': ma.URLFor(Meta.collection_url),
        'participant': ma.URLFor('api.participants', kf_id='<participant_id>')
    })
コード例 #8
0
class ReadGroupSchema(BaseSchema):

    lane_number = field_for(ReadGroup, 'lane_number',
                            validate=validate_positive_number)

    quality_scale = field_for(ReadGroup, 'quality_scale',
                              validate=enum_validation_generator(
                                  QUALITY_SCALE_ENUM, common=True))

    class Meta(BaseSchema.Meta):
        resource_url = 'api.read_groups'
        collection_url = 'api.read_groups_list'
        model = ReadGroup
        exclude = BaseSchema.Meta.exclude

    _links = ma.Hyperlinks({
        'self': ma.URLFor(Meta.resource_url, kf_id='<kf_id>'),
        'collection': ma.URLFor(Meta.collection_url),
        'read_group_genomic_files': ma.URLFor(
            'api.read_group_genomic_files_list', read_group_id='<kf_id>'),
        'genomic_files': ma.URLFor('api.genomic_files_list',
                                   read_group_id='<kf_id>')

    }, description='Resource links and pagination')
コード例 #9
0
class StudySchema(BaseSchema):

    investigator_id = field_for(Study, 'investigator_id',
                                required=False, load_only=True,
                                example='IG_ABB2C104')

    release_status = field_for(Study, 'release_status',
                               validate=enum_validation_generator(
                                   RELEASE_STATUS_ENUM))

    class Meta(BaseSchema.Meta):
        model = Study
        resource_url = 'api.studies'
        collection_url = 'api.studies_list'
        exclude = BaseSchema.Meta.exclude + ('participants', 'study_files')

    _links = ma.Hyperlinks({
        'self': ma.URLFor(Meta.resource_url, kf_id='<kf_id>'),
        'collection': ma.URLFor(Meta.collection_url),
        'investigator': PatchedURLFor('api.investigators',
                                      kf_id='<investigator_id>'),
        'participants': ma.URLFor('api.participants_list', study_id='<kf_id>'),
        'study_files': ma.URLFor('api.study_files_list', study_id='<kf_id>')
    })
コード例 #10
0
class SequencingExperimentSchema(BaseSchema):
    sequencing_center_id = field_for(SequencingExperiment,
                                     'sequencing_center_id',
                                     required=True,
                                     load_only=True)
    experiment_strategy = field_for(
        SequencingExperiment,
        'experiment_strategy',
        validate=enum_validation_generator(EXPERIMENT_STRATEGY_ENUM))
    platform = field_for(SequencingExperiment,
                         'platform',
                         validate=enum_validation_generator(PLATFORM_ENUM))
    library_strand = field_for(
        SequencingExperiment,
        'library_strand',
        validate=enum_validation_generator(LIBRARY_STRAND_ENUM))
    library_selection = field_for(
        SequencingExperiment,
        'library_selection',
        validate=enum_validation_generator(LIBRARY_SELECTION_ENUM))

    library_prep = field_for(
        SequencingExperiment,
        'library_prep',
        validate=enum_validation_generator(LIBRARY_PREP_ENUM))

    class Meta(BaseSchema.Meta):
        resource_url = 'api.sequencing_experiments'
        collection_url = 'api.sequencing_experiments_list'
        model = SequencingExperiment
        exclude = (BaseSchema.Meta.exclude + ('sequencing_center', ) +
                   ('genomic_files', ))

    max_insert_size = field_for(SequencingExperiment,
                                'max_insert_size',
                                validate=validate_positive_number)
    mean_insert_size = field_for(SequencingExperiment,
                                 'mean_insert_size',
                                 validate=validate_positive_number)
    mean_depth = field_for(SequencingExperiment,
                           'mean_depth',
                           validate=validate_positive_number)
    total_reads = field_for(SequencingExperiment,
                            'total_reads',
                            validate=validate_positive_number)
    mean_read_length = field_for(SequencingExperiment,
                                 'mean_read_length',
                                 validate=validate_positive_number)
    experiment_date = field_for(SequencingExperiment,
                                'experiment_date',
                                field_class=DateOrDatetime)

    _links = ma.Hyperlinks(
        {
            'self':
            ma.URLFor(Meta.resource_url, kf_id='<kf_id>'),
            'collection':
            ma.URLFor(Meta.collection_url),
            'sequencing_center':
            ma.URLFor('api.sequencing_centers',
                      kf_id='<sequencing_center_id>'),
            'sequencing_experiment_genomic_files':
            ma.URLFor('api.sequencing_experiment_genomic_files_list',
                      sequencing_experiment_id='<kf_id>'),
            'genomic_files':
            ma.URLFor('api.genomic_files_list',
                      sequencing_experiment_id='<kf_id>')
        },
        description='Resource links and pagination')
コード例 #11
0
class BiospecimenSchema(BaseSchema):
    participant_id = field_for(Biospecimen,
                               'participant_id',
                               required=True,
                               load_only=True)

    sequencing_center_id = field_for(Biospecimen,
                                     'sequencing_center_id',
                                     required=True,
                                     load_only=True)

    age_at_event_days = field_for(Biospecimen,
                                  'age_at_event_days',
                                  validate=validate_age)
    concentration_mg_per_ml = field_for(Biospecimen,
                                        'concentration_mg_per_ml',
                                        validate=validate_positive_number)
    volume_ul = field_for(Biospecimen,
                          'volume_ul',
                          validate=validate_positive_number)

    shipment_date = field_for(Biospecimen,
                              'shipment_date',
                              field_class=DateOrDatetime)
    analyte_type = field_for(
        Biospecimen,
        'analyte_type',
        validate=enum_validation_generator(ANALYTE_TYPE_ENUM))
    method_of_sample_procurement = field_for(
        Biospecimen,
        'method_of_sample_procurement',
        validate=enum_validation_generator(SAMPLE_PROCUREMENT_ENUM))
    duo_ids = field_for(Biospecimen,
                        'duo_ids',
                        validate=list_validation_generator(
                            DUO_ID_BIOSPECIMEN_ENUM, items_name='DUO IDs'))

    class Meta(BaseSchema.Meta):
        model = Biospecimen
        resource_url = 'api.biospecimens'
        collection_url = 'api.biospecimens_list'
        exclude = (BaseSchema.Meta.exclude +
                   ('participant', 'sequencing_center') +
                   ('biospecimen_genomic_files', 'biospecimen_diagnoses'))

    _links = ma.Hyperlinks({
        'self':
        ma.URLFor(Meta.resource_url, kf_id='<kf_id>'),
        'collection':
        ma.URLFor(Meta.collection_url),
        'participant':
        ma.URLFor('api.participants', kf_id='<participant_id>'),
        'sequencing_center':
        ma.URLFor('api.sequencing_centers', kf_id='<sequencing_center_id>'),
        'biospecimen_genomic_files':
        ma.URLFor('api.biospecimen_genomic_files_list',
                  biospecimen_id='<kf_id>'),
        'biospecimen_diagnoses':
        ma.URLFor('api.biospecimen_diagnoses_list', biospecimen_id='<kf_id>'),
        'diagnoses':
        ma.URLFor('api.diagnoses_list', biospecimen_id='<kf_id>'),
        'genomic_files':
        ma.URLFor('api.genomic_files_list', biospecimen_id='<kf_id>')
    })