Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _setup_gsa_test(resources_dir):
# reset resource if already loaded
r = Resources()
r._resources_dir = resources_dir
r._gsa_resources = {}
gzip_file(
"tests/resources/gsa_rsid_map.txt",
os.path.join(resources_dir, "gsa_rsid_map.txt.gz"),
)
gzip_file(
"tests/resources/gsa_chrpos_map.txt",
os.path.join(resources_dir, "gsa_chrpos_map.txt.gz"),
)
def _teardown_gsa_test():
r = Resources()
r._resources_dir = "resources"
r._gsa_resources = {}
def _setup_gsa_test(resources_dir):
# reset resource if already loaded
r = Resources()
r._resources_dir = resources_dir
r._gsa_resources = {}
gzip_file(
"tests/resources/gsa_rsid_map.txt",
os.path.join(resources_dir, "gsa_rsid_map.txt.gz"),
)
gzip_file(
"tests/resources/gsa_chrpos_map.txt",
os.path.join(resources_dir, "gsa_chrpos_map.txt.gz"),
)
def _setup_gsa_test(resources_dir):
# reset resource if already loaded
r = Resources()
r._resources_dir = resources_dir
r._gsa_resources = {}
gzip_file(
"tests/resources/gsa_rsid_map.txt",
os.path.join(resources_dir, "gsa_rsid_map.txt.gz"),
)
gzip_file(
"tests/resources/gsa_chrpos_map.txt",
os.path.join(resources_dir, "gsa_chrpos_map.txt.gz"),
)
def f():
s = SNPs("tests/input/GRCh37.csv")
chromosomes_remapped, chromosomes_not_remapped = s.remap_snps(38)
self.assertEqual(s.build, 38)
self.assertEqual(s.assembly, "GRCh38")
self.assertEqual(len(chromosomes_remapped), 2)
self.assertEqual(len(chromosomes_not_remapped), 0)
pd.testing.assert_frame_equal(s.snps, self.snps_GRCh38(), check_exact=True)
def f():
s = SNPs("tests/input/NCBI36.csv", parallelize=True)
chromosomes_remapped, chromosomes_not_remapped = s.remap_snps(37)
self.assertEqual(s.build, 37)
self.assertEqual(s.assembly, "GRCh37")
self.assertEqual(len(chromosomes_remapped), 2)
self.assertEqual(len(chromosomes_not_remapped), 0)
pd.testing.assert_frame_equal(s.snps, self.snps_GRCh37(), check_exact=True)
def test_chromosomes(self):
s = SNPs("tests/input/chromosomes.csv")
self.assertListEqual(s.chromosomes, ["1", "2", "3", "5", "PAR", "MT"])
def test_save_snps_specify_file(self):
s = SNPs("tests/input/generic.csv")
self.assertEqual(os.path.relpath(s.save_snps("snps.csv")), "output/snps.csv")
self.run_parsing_tests("output/snps.csv", "generic")
def test_save_snps_no_snps_vcf(self):
s = SNPs()
self.assertFalse(s.save_snps(vcf=True))
def parse_file(self, file, rsids=()):
return SNPs(file, rsids=rsids)