-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Modified pyspark validation to accomodate for custom functions * Added cds verification: * Added bio checks test cases * Added README updates
- Loading branch information
Showing
8 changed files
with
160 additions
and
9 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
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,40 @@ | ||
import pytest | ||
import polars as pl | ||
import duckdb | ||
|
||
def test_is_dna(check, db: duckdb.DuckDBPyConnection): | ||
df = pl.DataFrame({"sequence" : ["ATGCCCTTTGGGTAA", "ATGCCCTTTGGGTAG", "ATGCCCTTTGGGTGA"]}) | ||
check.table_name = "df" | ||
check.bio.is_dna("sequence") | ||
assert check.validate(db).status.str.match("PASS").all() | ||
|
||
def test_is_not_dna(check, db: duckdb.DuckDBPyConnection): | ||
df = pl.DataFrame({"sequence" : ["XXX", "YYY", "ZZZ"]}) | ||
check.table_name = "df" | ||
check.bio.is_dna("sequence") | ||
assert check.validate(db).status.str.match("FAIL").all() | ||
|
||
def test_is_cds(check, db: duckdb.DuckDBPyConnection): | ||
df = pl.DataFrame({"sequence" : ["ATGCCCTTTGGGTAA", "ATGCCCTTTGGGTAG", "ATGCCCTTTGGGTGA"]}) | ||
check.table_name = "df" | ||
check.bio.is_cds("sequence") | ||
assert check.validate(db).status.str.match("PASS").all() | ||
|
||
|
||
def test_is_not_cds(check, db: duckdb.DuckDBPyConnection): | ||
df = pl.DataFrame({"sequence" : ["ATGCCCTTTGGGTCC", "ATGCCCTTTGGGCCC", "ATGCCCTTTGGGTTT"]}) | ||
check.table_name = "df" | ||
check.bio.is_cds("sequence") | ||
assert check.validate(db).status.str.match("FAIL").all() | ||
|
||
def test_is_protein(check, db: duckdb.DuckDBPyConnection): | ||
df = pl.DataFrame({"sequence" : ["ARND", "PSTW", "GHIL"]}) | ||
check.table_name = "df" | ||
check.bio.is_protein("sequence") | ||
assert check.validate(db).status.str.match("PASS").all() | ||
|
||
def test_is_not_protein(check, db: duckdb.DuckDBPyConnection): | ||
df = pl.DataFrame({"sequence" : ["XXX", "OO1", "UU2"]}) | ||
check.table_name = "df" | ||
check.bio.is_protein("sequence") | ||
assert check.validate(db).status.str.match("FAIL").all() |
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,45 @@ | ||
import pytest | ||
import polars as pl | ||
|
||
def test_is_dna(check): | ||
df = pl.DataFrame({"sequence" : ["ATGCCCTTTGGGTAA", "ATGCCCTTTGGGTAG", "ATGCCCTTTGGGTGA"]}) | ||
check.bio.is_dna("sequence") | ||
rs = check.validate(df) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
def test_is_not_dna(check): | ||
df = pl.DataFrame({"sequence" : ["XXX", "YYY", "ZZZ"]}) | ||
check.bio.is_dna("sequence") | ||
rs = check.validate(df) | ||
result = check.validate(df).select(pl.col("status")) == "FAIL" | ||
assert all(result.to_series().to_list()) | ||
|
||
def test_is_cds(check): | ||
df = pl.DataFrame({"sequence" : ["ATGCCCTTTGGGTAA", "ATGCCCTTTGGGTAG", "ATGCCCTTTGGGTGA"]}) | ||
check.bio.is_cds("sequence") | ||
rs = check.validate(df) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_is_not_cds(check): | ||
df = pl.DataFrame({"sequence" : ["ATGCCCTTTGGGTCC", "ATGCCCTTTGGGCCC", "ATGCCCTTTGGGTTT"]}) | ||
check.bio.is_cds("sequence") | ||
rs = check.validate(df) | ||
result = check.validate(df).select(pl.col("status")) == "FAIL" | ||
assert all(result.to_series().to_list()) | ||
|
||
def test_is_protein(check): | ||
df = pl.DataFrame({"sequence" : ["ARND", "PSTW", "GHIL"]}) | ||
check.bio.is_protein("sequence") | ||
rs = check.validate(df) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
def test_is_not_protein(check): | ||
df = pl.DataFrame({"sequence" : ["XXX", "OO1", "UU2"]}) | ||
check.bio.is_protein("sequence") | ||
rs = check.validate(df) | ||
result = check.validate(df).select(pl.col("status")) == "FAIL" | ||
assert all(result.to_series().to_list()) |
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,50 @@ | ||
import pytest | ||
|
||
def test_is_dna(check, spark): | ||
df = spark.createDataFrame([("ATGCCCTTTGGGTAA",), ("ATGCCCTTTGGGTAG",), ("ATGCCCTTTGGGTGA",)], schema="sequence string") | ||
check.bio.is_dna("sequence") | ||
rs = check.validate(df) | ||
assert rs.first().status == "PASS" | ||
assert rs.first().violations == 0 | ||
assert rs.first().pass_threshold == 1.0 | ||
|
||
def test_is_not_dna(check, spark): | ||
df = spark.createDataFrame([("XXX",), ("YYY",), ("ZZZ",)], schema="sequence string") | ||
check.bio.is_dna("sequence") | ||
rs = check.validate(df) | ||
assert rs.first().status == "FAIL" | ||
assert rs.first().violations == 3 | ||
assert rs.first().pass_threshold == 1.0 | ||
|
||
def test_is_cds(check, spark): | ||
df = spark.createDataFrame([("ATGCCCTTTGGGTAA",), ("ATGCCCTTTGGGTAG",), ("ATGCCCTTTGGGTGA",)], schema="sequence string") | ||
check.bio.is_cds("sequence") | ||
rs = check.validate(df) | ||
assert rs.first().status == "PASS" | ||
assert rs.first().violations == 0 | ||
assert rs.first().pass_threshold == 1.0 | ||
|
||
|
||
def test_is_not_cds(check, spark): | ||
df = spark.createDataFrame([("ATGCCCTTTGGGTCC",), ("ATGCCCTTTGGGCCC",), ("ATGCCCTTTGGGTTT",)], schema="sequence string") | ||
check.bio.is_cds("sequence") | ||
rs = check.validate(df) | ||
assert rs.first().status == "FAIL" | ||
assert rs.first().violations == 3 | ||
assert rs.first().pass_threshold == 1.0 | ||
|
||
def test_is_protein(check, spark): | ||
df = spark.createDataFrame([("ARND",), ("PSTW",), ("GHIL",)], schema="sequence string") | ||
check.bio.is_protein("sequence") | ||
rs = check.validate(df) | ||
assert rs.first().status == "PASS" | ||
assert rs.first().violations == 0 | ||
assert rs.first().pass_threshold == 1.0 | ||
|
||
def test_is_not_protein(check, spark): | ||
df = spark.createDataFrame([("XXX",), ("OO1",), ("UU2",)], schema="sequence string") | ||
check.bio.is_protein("sequence") | ||
rs = check.validate(df) | ||
assert rs.first().status == "FAIL" | ||
assert rs.first().violations == 3 | ||
assert rs.first().pass_threshold == 1.0 |