-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from AI-sandbox/fixes
Some minor fixes and improvements mostly related to SNP readers
- Loading branch information
Showing
13 changed files
with
146 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import numpy as np | ||
|
||
from snputils import VCFReader, BEDReader, PGENReader | ||
|
||
|
||
# TODO: Fails with KeyError: 'calldata/GT' (genotypes = vcf_dict["calldata/GT"].astype(np.int8)) | ||
# def test_vcf_only_samples(data_path, snpobj_vcf): | ||
# snpobj_vcf_only_samples = VCFReader(data_path + "/subset.vcf").read(fields=["IID"]) | ||
# assert np.array_equal(snpobj_vcf_only_samples.samples, snpobj_vcf.samples) | ||
|
||
|
||
def test_bed_only_samples(data_path, snpobj_bed): | ||
snpobj_bed_only_samples = BEDReader(data_path + "/bed/subset").read(fields=["IID"]) | ||
assert np.array_equal(snpobj_bed_only_samples.samples, snpobj_bed.samples) | ||
|
||
|
||
def test_pgen_only_samples(data_path, snpobj_pgen): | ||
snpobj_pgen_only_samples = PGENReader(data_path + "/pgen/subset").read(fields=["IID"]) | ||
assert np.array_equal(snpobj_pgen_only_samples.samples, snpobj_pgen.samples) | ||
|
||
|
||
# TODO: Fails with KeyError: 'calldata/GT' (genotypes = vcf_dict["calldata/GT"].astype(np.int8)) | ||
# def test_vcf_only_variants(data_path, snpobj_vcf): | ||
# snpobj_vcf_only_variants = VCFReader(data_path + "/subset.vcf").read(fields=["ID"]) | ||
# assert np.array_equal(snpobj_vcf_only_variants.variants_id, snpobj_vcf.variants_id) | ||
|
||
|
||
def test_bed_only_variants(data_path, snpobj_bed): | ||
snpobj_bed_only_variants = BEDReader(data_path + "/bed/subset").read(fields=["ID"]) | ||
assert np.array_equal(snpobj_bed_only_variants.variants_id, snpobj_bed.variants_id) | ||
|
||
|
||
def test_pgen_only_variants(data_path, snpobj_pgen): | ||
snpobj_pgen_only_variants = PGENReader(data_path + "/pgen/subset").read(fields=["ID"]) | ||
assert np.array_equal(snpobj_pgen_only_variants.variants_id, snpobj_pgen.variants_id) | ||
|
||
|
||
# TODO: Fails with KeyError: 'samples' (samples=vcf_dict["samples"],) | ||
# def test_vcf_only_gt(data_path, snpobj_vcf): | ||
# snpobj_vcf_only_gt = VCFReader(data_path + "/subset.vcf").read(fields=["GT"]) | ||
# assert np.array_equal(snpobj_vcf_only_gt.calldata_gt, snpobj_vcf.calldata_gt) | ||
|
||
|
||
def test_bed_only_gt(data_path, snpobj_bed): | ||
snpobj_bed_only_gt = BEDReader(data_path + "/bed/subset").read(fields=["GT"]) | ||
assert np.array_equal(snpobj_bed_only_gt.calldata_gt, snpobj_bed.calldata_gt) | ||
|
||
|
||
def test_pgen_only_gt(data_path, snpobj_pgen): | ||
snpobj_pgen_only_gt = PGENReader(data_path + "/pgen/subset").read(fields=["GT"]) | ||
assert np.array_equal(snpobj_pgen_only_gt.calldata_gt, snpobj_pgen.calldata_gt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import numpy as np | ||
|
||
from snputils import VCFReader, BEDReader, PGENReader | ||
|
||
|
||
def test_vcf_summed_strands(snpobj_vcf, data_path): | ||
snpobj_vcf_summed_strands = VCFReader(data_path + "/vcf/subset.vcf").read(sum_strands=True) | ||
assert np.array_equal(snpobj_vcf.calldata_gt.sum(axis=2, dtype=np.int8), snpobj_vcf_summed_strands.calldata_gt) | ||
|
||
|
||
def test_bed_summed_strands(snpobj_bed, data_path): | ||
snpojb_bed_summed_strands = BEDReader(data_path + "/bed/subset").read(sum_strands=True) | ||
assert np.array_equal(snpobj_bed.calldata_gt.sum(axis=2, dtype=np.int8), snpojb_bed_summed_strands.calldata_gt) | ||
|
||
|
||
def test_pgen_summed_strands(snpobj_pgen, data_path): | ||
snpobj_pgen_summed_strands = PGENReader(data_path + "/pgen/subset").read(sum_strands=True) | ||
assert np.array_equal(snpobj_pgen.calldata_gt.sum(axis=2, dtype=np.int8), snpobj_pgen_summed_strands.calldata_gt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters