Exemple #1
0
 def test_translate_entrez_symbol(self):
     """
     Test translation from entrez to symbol when either standard name or
     systematic name is null.
     """
     # Test the gene that has standard name.
     translation = translate_genes(id_list=[101],
                                   from_id="Entrez",
                                   to_id="Symbol",
                                   organism="Mus computurus")
     self.assertEqual(translation, {101: ['std_101'], 'not_found': []})
     # Test the gene that does NOT have standard name.
     translation = translate_genes(id_list=[102],
                                   from_id="Entrez",
                                   to_id="Symbol",
                                   organism="Mus computurus")
     self.assertEqual(translation, {102: ['sys_102'], 'not_found': []})
Exemple #2
0
 def test_translate_symbol_entrez_diff_organisms2(self):
     """
     Same as previous test, but uses the other organism as input.
     """
     translation = translate_genes(id_list=['ACDC'],
                                   from_id="Symbol",
                                   to_id="Entrez",
                                   organism="Monitorus computurus")
     self.assertEqual(translation, {'ACDC': [5], 'not_found': []})
Exemple #3
0
 def test_translate_symbol_entrez_diff_organisms(self):
     """
     translate_genes() should be able to differentiate between different
     organism genes when passed identical symbols.
     """
     # This test also confirmed that when both standard name and systematic
     # name are available, the sysmbol will be standard name.
     translation = translate_genes(id_list=['ACDC'],
                                   from_id="Symbol",
                                   to_id="Entrez",
                                   organism="Mus computurus")
     self.assertEqual(translation, {'ACDC': [4], 'not_found': []})
Exemple #4
0
 def test_translate_entrez_standard_name_missing(self):
     """
     Test translation from entrez to standard names with a missing value.
     """
     translation = translate_genes(id_list=[1, 2, 3],
                                   from_id="Entrez",
                                   to_id="Standard name")
     self.assertEqual(translation, {
         1: [
             'G1',
         ],
         2: [
             'G2',
         ],
         'not_found': [3]
     })
Exemple #5
0
 def test_translate_entrez_entrez_missing(self):
     """
     Test translation from entrez to entrez with a missing value.
     """
     translation = translate_genes(id_list=[1, 2, 3],
                                   from_id="Entrez",
                                   to_id="Entrez")
     self.assertEqual(translation, {
         1: [
             1,
         ],
         2: [
             2,
         ],
         'not_found': [3]
     })
Exemple #6
0
 def test_translate_entrez_systematic_name(self):
     """
     Test translation from entrez to systematic names.
     """
     translation = translate_genes(id_list=[1, 2],
                                   from_id="Entrez",
                                   to_id="Systematic name")
     self.assertEqual(translation, {
         1: [
             'g1',
         ],
         2: [
             'g2',
         ],
         'not_found': []
     })
Exemple #7
0
 def test_translate_entrez_entrez(self):
     """
     Test translation from entrez to entrez.
     """
     translation = translate_genes(id_list=[1, 2],
                                   from_id="Entrez",
                                   to_id="Entrez")
     self.assertEqual(translation, {
         1: [
             1,
         ],
         2: [
             2,
         ],
         'not_found': []
     })
Exemple #8
0
 def test_translate_entrez_xrdb(self):
     """
     Test translation from entrez to ASDF.
     """
     translation = translate_genes(id_list=[1, 2],
                                   from_id="Entrez",
                                   to_id="ASDF")
     self.assertEqual(translation, {
         1: [
             'XRID1',
             'XRRID1',
         ],
         2: [
             'XRID2',
         ],
         'not_found': []
     })
Exemple #9
0
    def translate_gene_ids(self, request, **kwargs):
        self.method_check(request, allowed=['post'])
        self.throttle_check(request)

        # Extract relevant parameters
        gene_list = request.POST.getlist('gene_list')
        from_id = request.POST.get('from_id')
        to_id = request.POST.get('to_id')
        organism = request.POST.get('organism')

        # Call the translate_genes method in genes.utils to
        # do the actual translating.
        return_ids_dict = translate_genes(id_list=gene_list,
                                          from_id=from_id,
                                          to_id=to_id,
                                          organism=organism)

        return self.create_response(request, return_ids_dict)
Exemple #10
0
 def test_translate_xrdb_entrez(self):
     """
     Test translation from ASDF to entrez.
     """
     translation = translate_genes(id_list=['XRID1', 'XRRID1', 'XRID2'],
                                   from_id="ASDF",
                                   to_id="Entrez")
     self.assertEqual(translation, {
         'XRID1': [
             1,
         ],
         'XRRID1': [
             1,
         ],
         'XRID2': [
             2,
         ],
         'not_found': []
     })