diff --git a/species_data.py b/species_data.py index d16530bde5a9dc1c046735b6aa738d0158b07ecd..bd4290d1364b6e8a200911f99b4e0adc0641a197 100644 --- a/species_data.py +++ b/species_data.py @@ -72,8 +72,13 @@ class SpeciesData: self.species = clean_string(parameters_dictionary_description[constants.ORG_PARAM_DESC_SPECIES]) self.genus = clean_string(parameters_dictionary_description[constants.ORG_PARAM_DESC_GENUS]) self.strain = clean_string(parameters_dictionary_description[constants.ORG_PARAM_DESC_STRAIN]) + if self.strain is None: + self.strain = "" self.sex = clean_string(parameters_dictionary_description[constants.ORG_PARAM_DESC_SEX]) self.common_name = parameters_dictionary_description[constants.ORG_PARAM_DESC_COMMON_NAME] + if self.sex is None: + self.sex = "" + self.common_name = parameters_dictionary_description[constants.ORG_PARAM_DESC_COMMON_NAME] self.date = datetime.today().strftime("%Y-%m-%d") self.origin = parameters_dictionary_description[constants.ORG_PARAM_DESC_ORIGIN] @@ -104,8 +109,14 @@ class SpeciesData: self.genus_lowercase = self.genus.lower() self.species_lowercase = self.species.lower() - self.strain_lowercase = self.strain.lower() - self.sex_lowercase = self.sex.lower() + try: + self.strain_lowercase = self.strain.lower() + except AttributeError as exc: + self.strain_lowercase = None + try: + self.sex_lowercase = self.sex.lower() + except AttributeError as exc: + self.sex_lowercase = None self.genus_uppercase = self.genus[0].upper() + self.genus_lowercase[1:] self.genus_species = "{0}_{1}".format(self.genus_lowercase, self.species_lowercase) @@ -115,10 +126,15 @@ class SpeciesData: self.full_name_lowercase = self.full_name.lower() self.species_folder_name = "_".join(utilities.filter_empty_not_empty_items( - [self.genus_lowercase, self.species_lowercase, self.strain.lower(), - self.sex.lower()])["not_empty"]) + [self.genus_lowercase, + self.species_lowercase, + self.strain_lowercase, + self.sex_lowercase])["not_empty"]) self.dataset_prefix = self.strain_sex + # If both strain and sex are empty attributes, change the dataset prefix to nothing instead of "_" + if self.dataset_prefix == "_": + self.dataset_prefix = "" self.genome_filename = "{0}_v{1}.fasta".format(self.dataset_prefix, self.genome_version) self.gff_filename = "{0}_OGS{1}_{2}.gff".format(self.dataset_prefix, self.ogs_version, constants.DATA_DATE.replace("-",""))