class TestOntology(TestCase): def setUp(self): self.ontology = Ontology(999999999) def testConvertToID(self): self.assertEqual(convert_to_id('ENA', 'ontology'), 999999999) def testConvertFromID(self): self.assertEqual(convert_from_id(999999999, 'ontology'), 'ENA') def testShortNameProperty(self): self.assertEqual(self.ontology.shortname, 'ENA') def testTerms(self): obs = self.ontology.terms self.assertEqual(obs, [ 'Whole Genome Sequencing', 'Metagenomics', 'Transcriptome Analysis', 'Resequencing', 'Epigenetics', 'Synthetic Genomics', 'Forensic or Paleo-genomics', 'Gene Regulation Study', 'Cancer Genomics', 'Population Genomics', 'RNASeq', 'Exome Sequencing', 'Pooled Clone Sequencing', 'Other']) def test_user_defined_terms(self): obs = self.ontology.user_defined_terms self.assertEqual(obs, []) def test_term_type(self): obs = self.ontology.term_type('RNASeq') self.assertEqual('ontology', obs) obs = self.ontology.term_type('Sasquatch') self.assertEqual('not_ontology', obs) self.ontology.add_user_defined_term('Test Term') obs = self.ontology.term_type('Test Term') self.assertEqual('user_defined', obs) def test_add_user_defined_term(self): self.assertFalse('Test Term' in self.ontology.user_defined_terms) pre = len(self.ontology.user_defined_terms) self.ontology.add_user_defined_term('Test Term') post = len(self.ontology.user_defined_terms) self.assertTrue('Test Term' in self.ontology.user_defined_terms) self.assertEqual(post-pre, 1) def testContains(self): self.assertTrue('Metagenomics' in self.ontology) self.assertFalse('NotATerm' in self.ontology)
class TestOntology(TestCase): def setUp(self): self.ontology = Ontology(999999999) def testConvertToID(self): self.assertEqual(convert_to_id('ENA', 'ontology'), 999999999) def testConvertFromID(self): self.assertEqual(convert_from_id(999999999, 'ontology'), 'ENA') def testShortNameProperty(self): self.assertEqual(self.ontology.shortname, 'ENA') def testTerms(self): obs = self.ontology.terms self.assertEqual(obs, [ 'Whole Genome Sequencing', 'Metagenomics', 'Transcriptome Analysis', 'Resequencing', 'Epigenetics', 'Synthetic Genomics', 'Forensic or Paleo-genomics', 'Gene Regulation Study', 'Cancer Genomics', 'Population Genomics', 'RNASeq', 'Exome Sequencing', 'Pooled Clone Sequencing', 'Other' ]) def test_user_defined_terms(self): obs = self.ontology.user_defined_terms self.assertEqual(obs, []) def test_term_type(self): obs = self.ontology.term_type('RNASeq') self.assertEqual('ontology', obs) obs = self.ontology.term_type('Sasquatch') self.assertEqual('not_ontology', obs) self.ontology.add_user_defined_term('Test Term') obs = self.ontology.term_type('Test Term') self.assertEqual('user_defined', obs) def test_add_user_defined_term(self): self.assertFalse('Test Term' in self.ontology.user_defined_terms) pre = len(self.ontology.user_defined_terms) self.ontology.add_user_defined_term('Test Term') post = len(self.ontology.user_defined_terms) self.assertTrue('Test Term' in self.ontology.user_defined_terms) self.assertEqual(post - pre, 1) def testContains(self): self.assertTrue('Metagenomics' in self.ontology) self.assertFalse('NotATerm' in self.ontology)
def __init__(self, preprocessed_data_id, study_title, study_abstract, investigation_type, empty_value='no_data', new_investigation_type=None, pmids=None, **kwargs): self.preprocessed_data_id = preprocessed_data_id self.study_title = study_title self.study_abstract = study_abstract self.investigation_type = investigation_type self.empty_value = empty_value self.new_investigation_type = new_investigation_type self.sequence_files = [] self.study_xml_fp = None self.sample_xml_fp = None self.experiment_xml_fp = None self.run_xml_fp = None self.submission_xml_fp = None self.pmids = pmids if pmids is not None else [] self.ebi_dir = self._get_ebi_dir() if self.investigation_type == 'Other' and \ self.new_investigation_type is None: raise ValueError("If the investigation_type is 'Other' you have " " to specify a value for new_investigation_type.") ontology = Ontology(convert_to_id('ENA', 'ontology')) if ontology.term_type(self.investigation_type) == 'not_ontology': raise ValueError("The investigation type must be part of ENA's " "ontology, '%s' is not valid" % self.investigation_type) # dicts that map investigation_type to library attributes lib_strategies = {'metagenome': 'POOLCLONE', 'mimarks-survey': 'AMPLICON'} lib_selections = {'mimarks-survey': 'PCR'} lib_sources = {} # if the investigation_type is 'Other' we should use the value in # the new_investigation_type attribute to retrieve this information if self.investigation_type == 'Other': key = self.new_investigation_type else: key = self.investigation_type self.library_strategy = lib_strategies.get(key, "OTHER") self.library_source = lib_sources.get(key, "METAGENOMIC") self.library_selection = lib_selections.get(key, "unspecified") # This allows addition of other arbitrary study metadata self.additional_metadata = self._stringify_kwargs(kwargs) # This will hold the submission's samples, keyed by the sample name self.samples = {}
def __init__(self, preprocessed_data_id, study_title, study_abstract, investigation_type, empty_value='no_data', new_investigation_type=None, pmids=None, **kwargs): self.preprocessed_data_id = preprocessed_data_id self.study_title = study_title self.study_abstract = study_abstract self.investigation_type = investigation_type self.empty_value = empty_value self.new_investigation_type = new_investigation_type self.sequence_files = [] self.study_xml_fp = None self.sample_xml_fp = None self.experiment_xml_fp = None self.run_xml_fp = None self.submission_xml_fp = None self.pmids = pmids if pmids is not None else [] self.ebi_dir = self._get_ebi_dir() if self.investigation_type == 'Other' and \ self.new_investigation_type is None: raise ValueError("If the investigation_type is 'Other' you have " " to specify a value for new_investigation_type.") ontology = Ontology(convert_to_id('ENA', 'ontology')) if ontology.term_type(self.investigation_type) == 'not_ontology': raise ValueError("The investigation type must be part of ENA's " "ontology, '%s' is not valid" % self.investigation_type) # dicts that map investigation_type to library attributes lib_strategies = { 'metagenome': 'POOLCLONE', 'mimarks-survey': 'AMPLICON' } lib_selections = {'mimarks-survey': 'PCR'} lib_sources = {} # if the investigation_type is 'Other' we should use the value in # the new_investigation_type attribute to retrieve this information if self.investigation_type == 'Other': key = self.new_investigation_type else: key = self.investigation_type self.library_strategy = lib_strategies.get(key, "OTHER") self.library_source = lib_sources.get(key, "METAGENOMIC") self.library_selection = lib_selections.get(key, "unspecified") # This allows addition of other arbitrary study metadata self.additional_metadata = self._stringify_kwargs(kwargs) # This will hold the submission's samples, keyed by the sample name self.samples = {}