def test_autocomplete_name(self):
        suggestions = LocationService(db='test').autocomplete_name("N")
        self.assertEqual(suggestions, [
            'NADK', 'NCLN', 'NCRNA00115', 'NET15', 'NET59', 'NET7', 'NICALIN',
            'NIR', 'NOC2L', 'NPHP4'
        ])

        suggestions = LocationService(db='test').autocomplete_name("NO")
        self.assertEqual(suggestions, ['NOC2L'])
 def test_find_gene(self):
     rlist = LocationService(db='test').find(" NOC2L")
     self.assertIsInstance(rlist, list)
     self.assertEqual(len(rlist), 1)
     r = rlist[0]
     self.assertEqual(r.chrom, 'chr1')
     self.assertEqual(r.start, 879584)  # first snp occurrence
     self.assertEqual(r.end, 894689)  # last snp occurrence
 def test_find_gene_2locs(self):
     """This gene is annotated on 2 chromosomes, thus appears at two different locations"""
     rlist = LocationService(db='test').find("AGRN")
     self.assertIsInstance(rlist, list)
     self.assertEqual(len(rlist), 1)
     r = rlist[0]
     self.assertEqual(r.chrom, 'chr1')
     self.assertEqual(r.start, 955503)  # first snp occurrence
     self.assertEqual(r.end, 991496)  # last snp occurrence
 def test_find_chrom_only(self):
     rlist = LocationService(db='test').find("  chr1  ")
     self.assertIsInstance(rlist, list)
     self.assertEqual(len(rlist), 1)
     r = rlist[0]
     self.assertEqual(r.chrom, 'chr1')
     self.assertEqual(r.start,
                      69510)  # first snp occurrence (select all samples!)
     self.assertEqual(r.end, 167385327)  # last snp occurrence
Example #5
0
def location_names_autocomplete(request, db, prefix=''):
    """Return gene names starting with *prefix*."""
    ans = LocationService(db).autocomplete_name(prefix, maxi=10)
    return JsonResponse(ans, safe=False)
Example #6
0
def location_find(request, db, loc='', **kwargs):
    """Return an exposed GenomicRange for each location in the comma-separated list *loc*."""
    locs = LocationService(db).find(loc)
    locations = [l.expose() for l in locs]
    return JsonResponse(locations, safe=False)
Example #7
0
 def parse_arg(self, arg):
     """Return a list of `GenomicRange`s"""
     return LocationService(db=self.db).find(arg)
 def test_find_inexistent_feat(self):
     rlist = LocationService(db='test').find("chr77")
     self.assertEqual(rlist, [])
 def test_find_with_spaces(self):
     rlist = LocationService(db='test').find(
         "chr1,chr1:  955,503-955,503,AGRN,chr1:955,503-  955,503,chr1: 955,503- 955,503,NIR"
     )
     self.assertEqual(len(rlist), 6)
 def test_find_mix(self):
     rlist = LocationService(db='test').find("AGRN,chr2")
     self.assertEqual(len(rlist), 2)
 def test_find_region_with_commas(self):
     rlist = LocationService(db='test').find("chr1:955,503-955,503")
     self.assertEqual(len(rlist), 1)
 def test_find_region(self):
     rlist = LocationService(db='test').find("chrX:1-1000000")
     self.assertEqual(len(rlist), 1)
 def test_find_multiple_genes(self):
     rlist = LocationService(
         db='test').find("AGRN, NOC2L,NIR ,NET7,IDONTEXIST")
     self.assertEqual(len(rlist), 4)