Exemplo n.º 1
0
 def test_interaction_id_id_must_be_int(self, mock_json_retriever):
     mock_json_retriever.return_value = [
         self.interaction_json, self.interaction_json
     ]
     target = Target(self.target_json)
     with self.assertRaises(TypeError):
         target.get_interaction_by_id("1")
Exemplo n.º 2
0
 def test_can_get_interactions(self, mock_json_retriever):
     mock_json_retriever.return_value = [self.interaction_json, self.interaction_json]
     target = Target(self.target_json)
     interactions = target.interactions()
     self.assertIsInstance(interactions, list)
     self.assertEqual(len(interactions), 2)
     for interaction in interactions:
         self.assertIsInstance(interaction, Interaction)
Exemplo n.º 3
0
 def test_can_get_interaction_by_id(self, mock_json_retriever):
     mock_json_retriever.return_value = [
         self.interaction_json, self.interaction_json
     ]
     target = Target(self.target_json)
     interaction = target.get_interaction_by_id(
         self.interaction_json["interactionId"])
     self.assertIsInstance(interaction, Interaction)
Exemplo n.º 4
0
 def test_can_get_subunits(self, mock_json_retriever):
     mock_json_retriever.return_value = self.target_json
     target = Target(self.target_json)
     subunits = target.subunits()
     self.assertIsInstance(subunits, list)
     self.assertEqual(len(subunits), len(self.target_json["subunitIds"]))
     for subunit in subunits:
         self.assertIsInstance(subunit, Target)
Exemplo n.º 5
0
 def test_can_get_complexes(self, mock_json_retriever):
     mock_json_retriever.return_value = self.target_json
     target = Target(self.target_json)
     complexes = target.complexes()
     self.assertIsInstance(complexes, list)
     self.assertEqual(len(complexes), len(self.target_json["complexIds"]))
     for complex_ in complexes:
         self.assertIsInstance(complex_, Target)
Exemplo n.º 6
0
 def test_can_get_subunits(self, mock_json_retriever):
     mock_json_retriever.return_value = self.target_json
     target = Target(self.target_json)
     subunits = target.subunits()
     self.assertIsInstance(subunits, list)
     self.assertEqual(len(subunits), len(self.target_json["subunitIds"]))
     for subunit in subunits:
         self.assertIsInstance(subunit, Target)
Exemplo n.º 7
0
 def test_can_get_complexes(self, mock_json_retriever):
     mock_json_retriever.return_value = self.target_json
     target = Target(self.target_json)
     complexes = target.complexes()
     self.assertIsInstance(complexes, list)
     self.assertEqual(len(complexes), len(self.target_json["complexIds"]))
     for complex_ in complexes:
         self.assertIsInstance(complex_, Target)
Exemplo n.º 8
0
    def test_synonym_properties(self, mock_json_retriever):
        mock_json_retriever.return_value = [
         {"name": "ADRBRL1", "refs": []},
         {"name": "5-HT1A", "refs": []}
        ]
        target = Target(self.target_json)

        self.assertEqual(target.synonyms(), ["ADRBRL1", "5-HT1A"])
Exemplo n.º 9
0
 def test_can_get_uniprot_pdbs_when_no_results(self, mock_xml_retriever, mock_json_retriever):
     mock_json_retriever.return_value = [
      {"accession": "10576", "database": "UniProtKB", "species": "Human", "url":"http"}
     ]
     mock_xml_retriever.return_value = None
     target = Target(self.target_json)
     pdbs = target.uniprot_pdbs()
     self.assertEqual(pdbs, [])
Exemplo n.º 10
0
    def test_species_gene_properties(self, mock_json_retriever):
        mock_json_retriever.return_value = self.gene_json
        target = Target(self.target_json)

        genes = target.genes(species="mouse")
        self.assertEqual(len(genes), 1)
        self.assertIsInstance(genes[0], Gene)
        self.assertEqual(genes[0].gene_symbol(), "Kcnma1")
        self.assertEqual(genes[0].species(), "Mouse")
Exemplo n.º 11
0
    def test_species_database_properties(self, mock_json_retriever):
        mock_json_retriever.return_value = self.database_json
        target = Target(self.target_json)

        links = target.database_links(species="mouse")
        self.assertEqual(len(links), 1)
        self.assertIsInstance(links[0], DatabaseLink)
        self.assertEqual(links[0].accession(), "11863")
        self.assertEqual(links[0].species(), "Mouse")
Exemplo n.º 12
0
 def test_can_get_uniprot_pdbs_by_species(self, mock_xml_retriever, mock_json_retriever):
     mock_json_retriever.return_value = [
      {"accession": "10576", "database": "UniProtKB", "species": "Human", "url":"http"},
      {"accession": "10576", "database": "UniProtKB", "species": "Rat", "url":"http"}
     ]
     mock_xml_retriever.side_effect = [["2XG3", "3A1I"], ["1xxx"]]
     target = Target(self.target_json)
     pdbs = target.uniprot_pdbs(species="rat")
     self.assertEqual(pdbs, ["2XG3", "3A1I"])
Exemplo n.º 13
0
    def test_species_database_properties(self, mock_json_retriever):
        mock_json_retriever.return_value = self.database_json
        target = Target(self.target_json)

        links = target.database_links(species="mouse")
        self.assertEqual(len(links), 1)
        self.assertIsInstance(links[0], DatabaseLink)
        self.assertEqual(links[0].accession(), "11863")
        self.assertEqual(links[0].species(), "Mouse")
Exemplo n.º 14
0
    def test_species_gene_properties(self, mock_json_retriever):
        mock_json_retriever.return_value = self.gene_json
        target = Target(self.target_json)

        genes = target.genes(species="mouse")
        self.assertEqual(len(genes), 1)
        self.assertIsInstance(genes[0], Gene)
        self.assertEqual(genes[0].gene_symbol(), "Kcnma1")
        self.assertEqual(genes[0].species(), "Mouse")
Exemplo n.º 15
0
 def test_can_get_ligands(self, mock_json_retriever):
     mock_json_retriever.side_effect = [[
         self.interaction_json, self.interaction_json
     ], self.ligand_json, self.ligand_json]
     target = Target(self.target_json)
     ligands = target.ligands()
     self.assertIsInstance(ligands, list)
     self.assertEqual(len(ligands), 2)
     for ligand in ligands:
         self.assertIsInstance(ligand, Ligand)
Exemplo n.º 16
0
 def test_can_get_ligands(self, mock_json_retriever):
     mock_json_retriever.side_effect = [
      [self.interaction_json, self.interaction_json], self.ligand_json, self.ligand_json
     ]
     target = Target(self.target_json)
     ligands = target.ligands()
     self.assertIsInstance(ligands, list)
     self.assertEqual(len(ligands), 2)
     for ligand in ligands:
         self.assertIsInstance(ligand, Ligand)
Exemplo n.º 17
0
 def test_basic_property_methods(self):
     target = Target(self.target_json)
     self.assertIs(target._target_id, target.target_id())
     self.assertIs(target._name, target.name())
     self.assertIs(target._abbreviation, target.abbreviation())
     self.assertIs(target._systematic_name, target.systematic_name())
     self.assertIs(target._target_type, target.target_type())
     self.assertIs(target._family_ids, target.family_ids())
     self.assertIs(target._subunit_ids, target.subunit_ids())
     self.assertIs(target._complex_ids, target.complex_ids())
Exemplo n.º 18
0
 def test_can_get_interactions(self, mock_json_retriever):
     mock_json_retriever.return_value = [
         self.interaction_json, self.interaction_json
     ]
     target = Target(self.target_json)
     interactions = target.interactions()
     self.assertIsInstance(interactions, list)
     self.assertEqual(len(interactions), 2)
     for interaction in interactions:
         self.assertIsInstance(interaction, Interaction)
Exemplo n.º 19
0
    def test_database_properties(self, mock_json_retriever):
        mock_json_retriever.return_value = self.database_json
        target = Target(self.target_json)

        self.assertEqual(len(target.database_links()), 2)
        self.assertIsInstance(target.database_links()[0], DatabaseLink)
        self.assertIsInstance(target.database_links()[1], DatabaseLink)
        self.assertEqual(target.database_links()[0].accession(), "10576")
        self.assertEqual(target.database_links()[1].accession(), "11863")
        self.assertEqual(target.database_links()[0].species(), "Rat")
        self.assertEqual(target.database_links()[1].species(), "Mouse")
Exemplo n.º 20
0
 def test_can_get_all_pdbs(self, mock_xml_retriever, mock_json_retriever):
     mock_json_retriever.side_effect = [
      self.pdb_json,
      [{"accession": "10576", "database": "UniProtKB", "species": "Human", "url":"http"}]
     ]
     mock_xml_retriever.return_value = ["2XG3", "3A1I"]
     target = Target(self.target_json)
     pdbs = target.all_pdbs()
     self.assertEqual(len(pdbs), 4)
     for code in ["4IAQ", "4IAR", "2XG3", "3A1I"]:
         self.assertIn(code, pdbs)
Exemplo n.º 21
0
    def test_synonym_properties(self, mock_json_retriever):
        mock_json_retriever.return_value = [{
            "name": "ADRBRL1",
            "refs": []
        }, {
            "name": "5-HT1A",
            "refs": []
        }]
        target = Target(self.target_json)

        self.assertEqual(target.synonyms(), ["ADRBRL1", "5-HT1A"])
Exemplo n.º 22
0
 def test_can_get_uniprot_pdbs_when_no_results(self, mock_xml_retriever,
                                               mock_json_retriever):
     mock_json_retriever.return_value = [{
         "accession": "10576",
         "database": "UniProtKB",
         "species": "Human",
         "url": "http"
     }]
     mock_xml_retriever.return_value = None
     target = Target(self.target_json)
     pdbs = target.uniprot_pdbs()
     self.assertEqual(pdbs, [])
Exemplo n.º 23
0
 def test_basic_property_methods(self):
     target = Target(self.target_json)
     self.assertIs(target._target_id, target.target_id())
     self.assertIs(target._name, target.name())
     self.assertIs(target._abbreviation, target.abbreviation())
     self.assertIs(target._systematic_name, target.systematic_name())
     self.assertIs(target._target_type, target.target_type())
     self.assertIs(target._family_ids, target.family_ids())
     self.assertIs(target._subunit_ids, target.subunit_ids())
     self.assertIs(target._complex_ids, target.complex_ids())
Exemplo n.º 24
0
 def test_can_get_families(self, mock_json_retriever):
     mock_json_retriever.return_value = {
      "familyId": 1,
      "name": "5-Hydroxytryptamine receptors",
      "targetIds": [1, 2, 5],
      "parentFamilyIds": [694],
      "subFamilyIds": [9]
     }
     target = Target(self.target_json)
     families = target.families()
     self.assertIsInstance(families, list)
     self.assertEqual(len(families), len(self.target_json["familyIds"]))
     for family in families:
         self.assertIsInstance(family, TargetFamily)
Exemplo n.º 25
0
 def test_can_get_families(self, mock_json_retriever):
     mock_json_retriever.return_value = {
         "familyId": 1,
         "name": "5-Hydroxytryptamine receptors",
         "targetIds": [1, 2, 5],
         "parentFamilyIds": [694],
         "subFamilyIds": [9]
     }
     target = Target(self.target_json)
     families = target.families()
     self.assertIsInstance(families, list)
     self.assertEqual(len(families), len(self.target_json["familyIds"]))
     for family in families:
         self.assertIsInstance(family, TargetFamily)
Exemplo n.º 26
0
 def test_can_get_all_pdbs(self, mock_xml_retriever, mock_json_retriever):
     mock_json_retriever.side_effect = [
         self.pdb_json,
         [{
             "accession": "10576",
             "database": "UniProtKB",
             "species": "Human",
             "url": "http"
         }]
     ]
     mock_xml_retriever.return_value = ["2XG3", "3A1I"]
     target = Target(self.target_json)
     pdbs = target.all_pdbs()
     self.assertEqual(len(pdbs), 4)
     for code in ["4IAQ", "4IAR", "2XG3", "3A1I"]:
         self.assertIn(code, pdbs)
Exemplo n.º 27
0
 def test_can_get_uniprot_pdbs_by_species(self, mock_xml_retriever,
                                          mock_json_retriever):
     mock_json_retriever.return_value = [{
         "accession": "10576",
         "database": "UniProtKB",
         "species": "Human",
         "url": "http"
     }, {
         "accession": "10576",
         "database": "UniProtKB",
         "species": "Rat",
         "url": "http"
     }]
     mock_xml_retriever.side_effect = [["2XG3", "3A1I"], ["1xxx"]]
     target = Target(self.target_json)
     pdbs = target.uniprot_pdbs(species="rat")
     self.assertEqual(pdbs, ["2XG3", "3A1I"])
Exemplo n.º 28
0
 def test_can_create_target(self):
     target = Target(self.target_json)
     self.assertEqual(target.json_data, self.target_json)
     self.assertEqual(target._target_id, 1)
     self.assertEqual(target._name, "5-HT<sub>1A</sub> receptor")
     self.assertEqual(target._abbreviation, "5-HT")
     self.assertEqual(target._systematic_name, None)
     self.assertEqual(target._target_type, "GPCR")
     self.assertEqual(target._family_ids, [1])
     self.assertEqual(target._subunit_ids, [2, 3])
     self.assertEqual(target._complex_ids, [4])
Exemplo n.º 29
0
    def test_gene_properties(self, mock_json_retriever):
        mock_json_retriever.return_value = self.gene_json
        target = Target(self.target_json)

        self.assertEqual(len(target.genes()), 3)
        self.assertIsInstance(target.genes()[0], Gene)
        self.assertIsInstance(target.genes()[1], Gene)
        self.assertIsInstance(target.genes()[2], Gene)
        self.assertEqual(target.genes()[0].gene_symbol(), "KCNMA1")
        self.assertEqual(target.genes()[1].gene_symbol(), "Kcnma1")
        self.assertEqual(target.genes()[2].gene_symbol(), "Kcnma2")
Exemplo n.º 30
0
    def test_gene_properties(self, mock_json_retriever):
        mock_json_retriever.return_value = self.gene_json
        target = Target(self.target_json)

        self.assertEqual(len(target.genes()), 3)
        self.assertIsInstance(target.genes()[0], Gene)
        self.assertIsInstance(target.genes()[1], Gene)
        self.assertIsInstance(target.genes()[2], Gene)
        self.assertEqual(target.genes()[0].gene_symbol(), "KCNMA1")
        self.assertEqual(target.genes()[1].gene_symbol(), "Kcnma1")
        self.assertEqual(target.genes()[2].gene_symbol(), "Kcnma2")
Exemplo n.º 31
0
    def test_database_properties(self, mock_json_retriever):
        mock_json_retriever.return_value = self.database_json
        target = Target(self.target_json)

        self.assertEqual(len(target.database_links()), 2)
        self.assertIsInstance(target.database_links()[0], DatabaseLink)
        self.assertIsInstance(target.database_links()[1], DatabaseLink)
        self.assertEqual(target.database_links()[0].accession(), "10576")
        self.assertEqual(target.database_links()[1].accession(), "11863")
        self.assertEqual(target.database_links()[0].species(), "Rat")
        self.assertEqual(target.database_links()[1].species(), "Mouse")
Exemplo n.º 32
0
 def test_can_get_gtop_pdbs_by_species(self, mock_json_retriever):
     mock_json_retriever.return_value = self.pdb_json
     target = Target(self.target_json)
     pdbs = target.gtop_pdbs(species="rat")
     self.assertEqual(pdbs, ["4IAR"])
Exemplo n.º 33
0
 def test_gtop_pdbs_when_no_json(self, mock_json_retriever):
     mock_json_retriever.return_value = None
     target = Target(self.target_json)
     self.assertEqual(target.gtop_pdbs(), [])
Exemplo n.º 34
0
    def test_gene_properties_when_no_json(self, mock_json_retriever):
        mock_json_retriever.return_value = None
        target = Target(self.target_json)

        self.assertEqual(target.genes(), [])
Exemplo n.º 35
0
 def test_interactions_when_no_json(self, mock_json_retriever):
     mock_json_retriever.return_value = None
     target = Target(self.target_json)
     self.assertEqual(target.interactions(), [])
Exemplo n.º 36
0
 def test_cannot_get_interaction_by_invalid_id(self, mock_json_retriever):
     mock_json_retriever.return_value = None
     target = Target(self.target_json)
     with self.assertRaises(exceptions.NoSuchInteractionError):
         interaction = target.get_interaction_by_id(0)
Exemplo n.º 37
0
 def test_interactions_when_no_json(self, mock_json_retriever):
     mock_json_retriever.return_value = None
     target = Target(self.target_json)
     self.assertEqual(target.interactions(), [])
Exemplo n.º 38
0
 def test_cannot_get_interaction_by_invalid_id(self, mock_json_retriever):
     mock_json_retriever.return_value = None
     target = Target(self.target_json)
     with self.assertRaises(exceptions.NoSuchInteractionError):
         interaction = target.get_interaction_by_id(0)
Exemplo n.º 39
0
 def test_interaction_id_id_must_be_int(self, mock_json_retriever):
     mock_json_retriever.return_value =[self.interaction_json, self.interaction_json]
     target = Target(self.target_json)
     with self.assertRaises(TypeError):
         target.get_interaction_by_id("1")
Exemplo n.º 40
0
 def test_gtop_pdbs_when_no_json(self, mock_json_retriever):
     mock_json_retriever.return_value = None
     target = Target(self.target_json)
     self.assertEqual(target.gtop_pdbs(), [])
Exemplo n.º 41
0
 def test_can_get_gtop_pdbs_by_species(self, mock_json_retriever):
     mock_json_retriever.return_value = self.pdb_json
     target = Target(self.target_json)
     pdbs = target.gtop_pdbs(species="rat")
     self.assertEqual(pdbs, ["4IAR"])
Exemplo n.º 42
0
    def test_gene_properties_when_no_json(self, mock_json_retriever):
        mock_json_retriever.return_value = None
        target = Target(self.target_json)

        self.assertEqual(target.genes(), [])
Exemplo n.º 43
0
 def test_target_repr(self):
     target = Target(self.target_json)
     self.assertEqual(str(target),
                      "<Target 1 (5-HT<sub>1A</sub> receptor)>")
Exemplo n.º 44
0
 def test_can_get_interaction_by_id(self, mock_json_retriever):
     mock_json_retriever.return_value = [self.interaction_json, self.interaction_json]
     target = Target(self.target_json)
     interaction = target.get_interaction_by_id(self.interaction_json["interactionId"])
     self.assertIsInstance(interaction, Interaction)