Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
def test_not_null_snps(self):
s = SNPs("tests/input/generic.csv")
snps = self.generic_snps()
snps.drop("rs5", inplace=True)
pd.testing.assert_frame_equal(s.not_null_snps(), snps, check_exact=True)
def test_is_valid_True(self):
s = SNPs("tests/input/generic.csv")
self.assertTrue(s.is_valid())
def empty_snps():
return [SNPs(), SNPs(b""), SNPs("tests/input/empty.txt")]
def get_xy_chrom_snp_ratios(task):
file = task["file"]
try:
logger.info("loading {}".format(file))
s = SNPs(r.load_opensnp_datadump_file(file), assign_par_snps=False)
except Exception as err:
logger.error("{}#{}".format(file, err))
return None
try:
if s.snp_count != 0:
# get X chromosome statistics
x_snps = len(s.snps.loc[(s.snps["chrom"] == "X")])
heterozygous_x_snps = len(
s.snps.loc[
(s.snps["chrom"] == "X")
& (s.snps["genotype"].notnull())
& (s.snps["genotype"].str.len() == 2)
& (s.snps["genotype"].str[0] != s.snps["genotype"].str[1])
]
)