def test_metadata_clean_function(self): test1 = "abc\tdef2" test2 = """ abc\tdef! """ self.assertEqual(MetadataValidator.clean_value(test1), "abc def2") self.assertEqual(MetadataValidator.clean_value(test2), "abc def")
def validate_metadata(self, data): validator = MetadataValidator() try: validator.validate(data) except MetadataValidationException as e: raise serializers.ValidationError(e) return data
def validate_metadata(self, data): validator = MetadataValidator() try: validator.validate(data) except MetadataValidationException as e: print("ERROR in validation") return data return data
def generate_sample_data_content(files, pipeline_name, pipeline_github, pipeline_version): result = "SAMPLE_ID\tREQUEST_ID\tPROJECT_ID\tPATIENT_ID\tCOLLAB_ID\tSAMPLE_TYPE\tGENE_PANEL\tONCOTREE_CODE\tSAMPLE_CLASS\tSPECIMEN_PRESERVATION_TYPE\tSEX\tTISSUE_SITE\tIGO_ID\tRUN_MODE\tPIPELINE\tPIPELINE_GITHUB_LINK\tPIPELINE_VERSION\n" ret_str = "metadata__sampleId" query = Q(file__file_group_id=settings.IMPORT_FILE_GROUP) query |= Q(file__file_group__slug="origin-unknown") query |= Q(file__file_group__slug="fero-legacy-data") query = query & Q(file__path__in=files) samples = FileRepository.filter( q=query).order_by(ret_str).distinct(ret_str).all() for sample in samples: metadata = sample.metadata result += "{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n".format( metadata.get( "cmoSampleName", format_sample_name(metadata["sampleName"], metadata["specimenType"])), metadata["requestId"], get_project_id(metadata["requestId"]), metadata["patientId"], metadata["investigatorSampleId"], MetadataValidator.clean_value(metadata["sampleClass"]), MetadataValidator.clean_value(metadata["recipe"]), MetadataValidator.clean_value(metadata["oncoTreeCode"]), MetadataValidator.clean_value(metadata["specimenType"]), MetadataValidator.clean_value(metadata["preservation"]), MetadataValidator.clean_value(metadata["sex"]), MetadataValidator.clean_value(metadata["tissueLocation"]), metadata["sampleId"], MetadataValidator.clean_value(metadata["runMode"]), pipeline_name, pipeline_github, pipeline_version, ) return result