Builds PaperTrail from the base skeleton into a full evidence-verification platform for the "Built with Claude: Life Sciences" hackathon (Builder Track). New named-user features (Build Beyond the Bench): - Lab Notebook Companion — rough bench notes -> structured, searchable, grounded experiment records (lib/labNotebook, /console/lab-notebook, migration 0059) - Clinical Trial Matcher — de-identified patient notes -> ranked eligible ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning (lib/trialMatcher, /console/trial-matcher, migrations 0060) Platform: - Deterministic verification moat (biostats recompute, exact-span grounding) - 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar, PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier) - Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise governance (RBAC, /api/v1 gateway, metering, audit chain, retention) - 17 OSS projects assimilated into native TypeScript on our stack (backend/engines retained + credited in NOTICE) - Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site - Next.js 16 upgrade, benchmark harness (honest smoke-test caveat) Licensing: Apache-2.0 (LICENSE + NOTICE).
133 lines
3.4 KiB
Python
133 lines
3.4 KiB
Python
import urllib
|
|
from pathlib import Path
|
|
|
|
import pandas as pd
|
|
from pytest import mark
|
|
|
|
import asreview as asr
|
|
from asreview.data.search import fuzzy_find
|
|
from asreview.data.utils import duplicated
|
|
from asreview.datasets import DatasetManager
|
|
|
|
|
|
def exists(url):
|
|
return urllib.request.urlopen(url).getcode() == 200
|
|
|
|
|
|
@mark.parametrize(
|
|
"keywords,record_id",
|
|
[
|
|
("bronchogenic duplication cyst", 0),
|
|
("diagnositc accuracy microscopy female priority", 1),
|
|
("immunophenotiping", 4),
|
|
("Foregut report embryoogenesis", 4),
|
|
("Liu Adler", 0),
|
|
("Khoury cysts", 4),
|
|
("Isolated Edwards", 5),
|
|
("Kwintanilla-djeck Neck", 3),
|
|
("Cancer case computer contrast pancreatomy Yamada", 2),
|
|
],
|
|
)
|
|
def test_fuzzy_finder(keywords, record_id):
|
|
fp = Path("tests", "demo_data", "embase.csv")
|
|
with asr.load_dataset(fp) as db:
|
|
assert fuzzy_find(db.input, keywords)[0] == record_id
|
|
|
|
|
|
@mark.internet_required
|
|
@mark.parametrize(
|
|
"data_name",
|
|
[
|
|
"synergy:Menon_2022",
|
|
"synergy:Meijboom_2021",
|
|
],
|
|
)
|
|
def test_datasets(data_name):
|
|
data = DatasetManager().find(data_name)
|
|
assert data.dataset_id == data_name[8:]
|
|
|
|
|
|
@mark.xfail(reason="Deduplication will be reimplemented.")
|
|
def test_duplicate_count():
|
|
db = asr.load_dataset(Path("tests", "demo_data", "duplicate_records.csv"))
|
|
|
|
assert int(db.input.df.duplicated("doi").sum()) == 2
|
|
|
|
|
|
def test_deduplication():
|
|
db_dups = asr.load_dataset(Path("tests", "demo_data", "duplicate_records.csv"))
|
|
|
|
s_dups_bool = pd.Series(
|
|
[
|
|
False,
|
|
True,
|
|
False,
|
|
True,
|
|
False,
|
|
False,
|
|
False,
|
|
False,
|
|
False,
|
|
False,
|
|
False,
|
|
False,
|
|
False,
|
|
False,
|
|
]
|
|
)
|
|
|
|
pd.testing.assert_series_equal(
|
|
duplicated(db_dups.input), s_dups_bool, check_index=False
|
|
)
|
|
|
|
|
|
def test_duplicated():
|
|
data = pd.DataFrame(
|
|
{
|
|
"doi": [
|
|
"https://www.doi.org/10.1000/xyz",
|
|
"https://www.doi.org/10.1000/abc",
|
|
"https://www.doi.org/10.1000/xyz",
|
|
"https://www.doi.org/10.1000/XYZ",
|
|
"10.1000/xyz",
|
|
"10.1000/xyz",
|
|
"http://www.doi.org/10.1000/xyz",
|
|
"https://doi.org/10.1000/xyz",
|
|
],
|
|
"title": ["T1", "T2", "T3", "T3", "T4", "T1", "T2", "T3"],
|
|
"abstract": ["A1", "A2", "A3", "A3", "A4", "A1", "A2", "A3"],
|
|
}
|
|
)
|
|
|
|
# Call the function and get the result
|
|
result = duplicated(data)
|
|
|
|
# Check the result
|
|
assert result.equals(pd.Series([False, False, True, True, True, True, True, True]))
|
|
|
|
|
|
def test_duplicated_empty_pid():
|
|
data = pd.DataFrame(
|
|
{
|
|
"title": ["T1", "T2", "T3", "T4", "T5", "T6"],
|
|
"abstract": ["A1", "A2", "A3", "A4", "A5", "A6"],
|
|
"doi": [None, None, None, None, None, None],
|
|
}
|
|
)
|
|
|
|
result = duplicated(data, pid=None)
|
|
assert result.equals(pd.Series([False, False, False, False, False, False]))
|
|
|
|
|
|
def test_duplicated_all_empty():
|
|
data = pd.DataFrame(
|
|
{
|
|
"title": ["", "", "", "", "", ""],
|
|
"abstract": ["", "", "", "", "", ""],
|
|
"doi": [None, None, None, None, None, None],
|
|
}
|
|
)
|
|
|
|
result = duplicated(data)
|
|
assert result.equals(pd.Series([False, False, False, False, False, False]))
|