How to use the snps.SNPs function in snps

To help you get started, we’ve selected a few snps examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apriha / snps / tests / test_snps.py View on Github external
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)
github apriha / snps / tests / test_snps.py View on Github external
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)
github apriha / snps / tests / test_snps.py View on Github external
def test_chromosomes(self):
        s = SNPs("tests/input/chromosomes.csv")
        self.assertListEqual(s.chromosomes, ["1", "2", "3", "5", "PAR", "MT"])
github apriha / snps / tests / io / test_writer.py View on Github external
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")
github apriha / snps / tests / test_snps.py View on Github external
def test_save_snps_no_snps_vcf(self):
        s = SNPs()
        self.assertFalse(s.save_snps(vcf=True))
github apriha / snps / tests / __init__.py View on Github external
def parse_file(self, file, rsids=()):
        return SNPs(file, rsids=rsids)
github apriha / snps / tests / test_snps.py View on Github external
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)
github apriha / snps / tests / test_snps.py View on Github external
def test_is_valid_True(self):
        s = SNPs("tests/input/generic.csv")
        self.assertTrue(s.is_valid())
github apriha / snps / tests / test_snps.py View on Github external
def empty_snps():
        return [SNPs(), SNPs(b""), SNPs("tests/input/empty.txt")]
github apriha / snps / analysis / xy-chrom-snp-ratios / xy-chrom-snp-ratios.py View on Github external
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])
                ]
            )