Beispiel #1
0
    def test2(self):
        old_dir = os.getcwd()
        os.chdir(os.path.dirname(os.path.realpath(__file__)))

        logging.info("in TestBgen test2")
        bgen = Bgen("../examples/bits1.bgen")
        bgen.read()
        bgen2 = bgen[:2, ::3]
        bgen2.read()
        os.chdir(old_dir)
Beispiel #2
0
    def test1(self):
        old_dir = os.getcwd()
        os.chdir(os.path.dirname(os.path.realpath(__file__)))

        logging.info("in TestBgen test1")
        bgen = Bgen('../examples/example.bgen')
        distdata = bgen.read()
        bgen2 = bgen[:2, ::3]
        distdata2 = bgen2.read()
        os.chdir(old_dir)
Beispiel #3
0
    def test2(self):
        from pysnptools.distreader import Bgen

        old_dir = os.getcwd()
        os.chdir(os.path.dirname(os.path.realpath(__file__)))

        bgen = Bgen('../examples/example.bgen')
        distmemmap = DistMemMap.write("tempdir/bgentomemmap.dist.memamp", bgen)
        assert DistData.allclose(bgen.read(),
                                 distmemmap.read(),
                                 equal_nan=True)
        os.chdir(old_dir)
Beispiel #4
0
 def test_bgen_reader_without_metadata(self):
     with example_filepath("example.32bits.bgen") as filepath:
         bgen = Bgen(filepath)
         bgen.read()
         samples = bgen.iid
         assert samples[-1, 1] == "sample_500"
Beispiel #5
0
                       dist_gen,
                       bits=8,
                       compression="zlib",
                       cleanup_temp_files=False)
            # print(os.path.getsize(filename))

    # if False: #!!!c,l
    #    from pysnptools.distreader import Bgen
    #    bgen = Bgen(r'D:\OneDrive\programs\hide\bgen-reader-py\bgen_reader\_example\complex.23bits.no.samples.bgen',allow_complex=True)
    #    print(bgen.sid_count)

    if False:
        from pysnptools.distreader import Bgen

        bgen = Bgen(r"M:\deldir\2500x100.bgen")
        bgen.read()
        print(bgen.shape)
        print("")

    if False:
        from pysnptools.distreader import Bgen

        bgen = Bgen(r"M:\deldir\1x1000000.bgen", verbose=True)
        print(bgen.shape)
        print("")

    if False:
        from pysnptools.distreader import Bgen

        bgen2 = Bgen(r"M:\deldir\10x5000000.bgen", verbose=True)
        print(bgen2.shape)
Beispiel #6
0
# Download a sample file
from pysnptools.util import example_file
bgen_file = example_file("pysnptools/examples/example.bgen")

# Read from the file
from pysnptools.distreader import Bgen
bgen = Bgen(bgen_file)  # Create a reader
probs0 = bgen[:, 0].read().val  # Read 1st SNP
print(probs0.shape)  # Shape of the NumPy array
assert probs0.shape == (500, 1, 3)

probs_all = bgen.read().val  # Read all variants
print(probs_all.shape)  # Shape of the NumPy array
assert probs_all.shape == (500, 199, 3)