Esempio n. 1
0
 def get_release_date(data: Submission) -> date:
     if 'study' in data.get_entity_types():
         for study in data.get_entities('study'):
             if 'release_date' in study.attributes:
                 release_date = date.fromisoformat(study.attributes['release_date'])
                 if release_date > date.today():
                     return release_date
Esempio n. 2
0
    def get_ena_files(self, data: Submission) -> Dict[str, Tuple[str, str]]:
        ena_files = {}
        for entity_type, converter in self.conversion_map:
            ena_type = converter.ena_type.upper()
            ena_set = etree.XML(f'<{ena_type}_SET />')
            for entity in data.get_entities(entity_type):
                ena_conversion = self.convert_entity(converter, data, entity)
                ena_set.append(ena_conversion)

            if len(ena_set) > 0:
                ena_files[ena_type] = (f'{ena_type}.xml', self.make_ena_file(ena_set))
        return ena_files
Esempio n. 3
0
    def validate_data(self, data: Submission):
        for entity_type, converter in self.converter.conversion_map:
            ena_type = converter.ena_type.upper()
            entities = data.get_entities(entity_type)
            logging.info(f'Validating {len(entities)} {entity_type}(s) against ENA {ena_type} schema')
            for entity in entities:
                schema = self.ena_schema[ena_type]
                ena_set = etree.XML(f'<{ena_type}_SET />')
                ena_set.append(self.converter.convert_entity(converter, data, entity))

                if not schema(ena_set):
                    self.add_errors(schema, ena_type, entity_type, entity)
Esempio n. 4
0
 def make_manifests(self, submission: Submission) -> Dict[str, str]:
     manifests = {}
     for run_experiment in submission.get_entities('run_experiment'):
         samples = submission.get_linked_entities(run_experiment, 'sample')
         studies = submission.get_linked_entities(run_experiment, 'study')
         if len(samples) == 1 and len(studies) == 1 and 'uploaded_file_1' in run_experiment.attributes:
             sample = samples.pop()
             study = studies.pop()
             sample_accession = sample.get_first_accession(SAMPLE_ACCESSION_PRIORITY)
             study_accession = study.get_accession('ENA_Study')
             if sample_accession and study_accession:
                 file_name, content = self.make_manifest(run_experiment, sample_accession, study_accession)
                 manifests[file_name] = content
     return manifests
Esempio n. 5
0
 def validate_data(self, data: Submission):
     entities = data.get_entities('run_experiment')
     logging.info(f'Validating file checksums for {len(entities)} run(s)')
     for entity in entities:
         self.validate_entity(entity)
Esempio n. 6
0
 def validate_data(self, data: Submission):
     entities = data.get_entities('sample')
     logging.info(f'Validating taxonomy against scientific name in {len(entities)} sample(s)')
     for entity in entities:
         self.validate_entity(entity)