Skip to content

Commit 3adace6

Browse files
Address report output and DAVID review
1 parent 4118189 commit 3adace6

8 files changed

Lines changed: 77 additions & 30 deletions

File tree

‎ChangeLog.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ the original 2.1.3 scripts to the Python-only CopraRNA2 runtime.
1919
potentially rankings; independently captured fixtures for unchanged extraction,
2020
statistics and reports remain untouched. Test explicit boundary contracts and
2121
real IntaRNAsTar interactions, including the effect of genomic folding context.
22+
- **Simplify missing report fields and update DAVID access.** Following review of
23+
[PR #7](https://github.com/BackofenLab/CopraRNA/pull/7) and the convention in
24+
[upstream issue #22](https://github.com/PatrickRWright/CopraRNA/issues/22), write
25+
unavailable values as empty cells in published result and web tables instead of
26+
the internal `NA` marker. This makes CSV imports unambiguous without changing
27+
statistical missing-value handling. Authenticate DAVID requests with the shared
28+
`rna@informatik.uni-freiburg.de` account instead of the former personal address.
2229
- **Remove static organism catalogs.** `CopraRNA_available_organisms.txt` supplied
2330
display names and an input allow-list; `kegg2refseqnew.csv` supplied assembly
2431
membership and arbitrary organism codes. Neither is necessary: resolve current

‎README.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,18 +324,19 @@ coprarna run --workdir /data/jobs/balanced --srnaseq /data/my_sRNAs.fa \
324324
Result columns include FDR-adjusted and comparative p-values, per-organism locus
325325
annotations and interaction coordinates, additional homologs and retained report
326326
fields. Coordinates follow IntaRNA's 1-based conventions relative to the extracted
327-
sequences. A missing comparative score (`NA`) is not evidence of a significant
327+
sequences. Final result and web tables write unavailable values as empty cells
328+
rather than `NA`; a missing comparative score is not evidence of a significant
328329
interaction. Ranking identifies candidates for biological follow-up, not validated
329330
regulation. Review the 16S tree and weight warnings when an outlier dominates.
330331

331332
All scientific diagrams are vector PDF/SVG. Extended PDFs retain every page, and
332333
the matching SVG stacks those pages. `--websrv` adds `coprarna_websrv_table.csv`,
333334
interaction details and SVG thumbnails. `--enrich N` writes optional functional
334335
reports under `Enrichment/`. DAVID requires a reachable compatible SOAP service
335-
and the account configured by the adapter; offline tests validate request
336-
contracts, not live service availability. The optional interactive HTML enrichment
337-
report loads upstream JavaScript when opened. Core prediction does not need a
338-
browser or DAVID.
336+
and authenticates as `rna@informatik.uni-freiburg.de`; offline tests validate
337+
request contracts, not live service availability. The optional interactive HTML
338+
enrichment report loads upstream JavaScript when opened. Core prediction does not
339+
need a browser or DAVID.
339340

340341
## Independent batches and helpers
341342

‎coprarna/conservation.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
from Bio import SeqIO
88

9-
from .runtime import command, options, srna_input
9+
from .runtime import command, srna_input
1010
from .rcompat import read_table, write_table, save_rdata, format_matrix_column
1111
from .rcompat import RNamedList
1212
from .statistics import r_number

‎coprarna/david.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
WSDL = "https://david-d.ncifcrf.gov/webservice/services/DAVIDWebService?wsdl"
77
ENDPOINT = "https://david-d.ncifcrf.gov/webservice/services/DAVIDWebService.DAVIDWebServiceHttpSoap11Endpoint/"
8+
EMAIL = "rna@informatik.uni-freiburg.de"
89

910

1011
def _report(path, count, copra, client_factory=None):
@@ -32,7 +33,7 @@ def emit(value):
3233
client = client_factory(WSDL)
3334
client.wsdl.services[0].setlocation(ENDPOINT)
3435
emit(client)
35-
emit(client.service.authenticate("patrickrw@gmx.net"))
36+
emit(client.service.authenticate(EMAIL))
3637
emit(
3738
client.service.addList(
3839
",".join(background[:count]), "ENTREZ_GENE_ID", "make_up", 0

‎coprarna/homology.py‎

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,32 @@ def run_domclust(directory):
102102
(directory / "cluster.tab").write_text(table)
103103

104104

105+
def _finalize_result_table(path):
106+
"""Publish a result CSV with empty missing cells and no internal sort column.
107+
108+
Rewrite ``path`` in place, converting only complete ``NA`` fields so text that
109+
happens to contain those letters is unchanged. Return the removed sort-column
110+
values for the optional webserver alignment map. Reject empty or malformed
111+
input rather than silently publishing a shifted table.
112+
"""
113+
lines = path.read_text().splitlines()
114+
fields = [line.split(",") for line in lines]
115+
if not fields or any(len(row) < 2 for row in fields):
116+
raise ValueError(f"Malformed result table: {path}")
117+
internal_sorting = [row[-1] for row in fields]
118+
published = [
119+
["" if cell == "NA" else cell for cell in row[:-1]] for row in fields
120+
]
121+
text = "\n".join(",".join(row) for row in published) + "\n"
122+
text = (
123+
text.replace(",Additional.homologs,", ",Additional homologs,")
124+
.replace(",Amount.sampled", ",Amount sampled")
125+
.replace("p.value", "p-value")
126+
)
127+
path.write_text(text)
128+
return internal_sorting
129+
130+
105131
def run_homology(
106132
srna: Path,
107133
up: int,
@@ -319,18 +345,11 @@ def keep(line):
319345
plot_evolutionary_heatmap(directory)
320346
for filename in ("CopraRNA_result.csv", "CopraRNA_result_all.csv"):
321347
path = directory / filename
322-
lines = path.read_text().splitlines()
348+
internal_sorting = _finalize_result_table(path)
323349
if filename == "CopraRNA_result.csv" and int(opt["websrv"]):
324350
(directory / "CopraRNA_result.map_evo_align").write_text(
325-
"\n".join(line.split(",")[-1] for line in lines) + "\n"
351+
"\n".join(internal_sorting) + "\n"
326352
)
327-
text = "\n".join(",".join(line.split(",")[:-1]) for line in lines) + "\n"
328-
text = (
329-
text.replace(",Additional.homologs,", ",Additional homologs,")
330-
.replace(",Amount.sampled", ",Amount sampled")
331-
.replace("p.value", "p-value")
332-
)
333-
path.write_text(text)
334353
if int(opt["websrv"]):
335354
from .webserver import export_prediction
336355

‎coprarna/webserver.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ def shorten(value, isleft):
7373
def prepare_webserver_output(result: Path, interactions: Path, directory: Path) -> str:
7474
"""Write the frontend table from comparative rows and native-derived duplexes.
7575
76-
Keep rows with missing comparative probabilities as NA; the more selective
77-
sTar personality can leave valid organism interactions without a combined score."""
76+
Emit missing comparative probabilities as empty fields; the more selective
77+
sTar personality can leave valid organism interactions without a combined score.
78+
Write ``coprarna_internal_table.csv`` and raise ``ValueError`` for an empty input.
79+
"""
7880
lines = result.read_text().splitlines()
7981
ui = interactions.read_text().splitlines()
8082
if len(lines) <= 1:
@@ -103,7 +105,7 @@ def prepare_webserver_output(result: Path, interactions: Path, directory: Path)
103105
interaction = prune_interaction(*block[1:5], target, query)
104106

105107
def number(value, precision):
106-
return "NA" if value in ("", "NA") else format(float(value), precision)
108+
return "" if value in ("", "NA") else format(float(value), precision)
107109

108110
fields = [
109111
str(rank),
@@ -126,7 +128,7 @@ def number(value, precision):
126128
block[13],
127129
"0",
128130
]
129-
output.append(",".join(fields) + "\n")
131+
output.append(",".join("" if field == "NA" else field for field in fields) + "\n")
130132
(directory / "coprarna_internal_table.csv").write_text("".join(output))
131133
return ""
132134

‎tests/test_adapters.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313

1414

1515
@pytest.mark.parametrize("copra", [True, False])
16-
def test_david_requests_and_stdout_match_captured_source(copra, tmp_path, monkeypatch):
17-
pytest.importorskip("suds.client")
18-
import suds.client
19-
16+
def test_david_requests_and_stdout_match_captured_source(copra, tmp_path):
2017
calls = []
2118

2219
class Service:
@@ -42,7 +39,6 @@ def __init__(self, url):
4239
def __str__(self):
4340
return "offline DAVID client"
4441

45-
monkeypatch.setattr(suds.client, "Client", Client)
4642
path = tmp_path / "prediction.csv"
4743
if copra:
4844
path.write_bytes(
@@ -59,6 +55,10 @@ def __str__(self):
5955
expected = json.loads(
6056
(FIXTURES / "david" / ("copra.json" if copra else "intarna.json")).read_text()
6157
)
58+
# The retained capture used the former personal DAVID account. Keep the
59+
# independently captured request fixture intact and apply the reviewed account
60+
# change explicitly at the contract boundary.
61+
expected["calls"][2][1] = [david.EMAIL]
6262
actual = (david.coprarna_report if copra else david.intarna_report)(path, 5, Client)
6363
assert actual == expected["stdout"]
6464
assert json.loads(json.dumps(calls)) == expected["calls"]

‎tests/test_review.py‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import pytest
1212

13-
from coprarna import genome, intarna, ncbi, parameters, pipeline, phylogeny
13+
from coprarna import genome, homology, intarna, ncbi, parameters, pipeline, phylogeny
1414
from coprarna.cli import main
1515
from coprarna.helpers import HELPERS
1616
from coprarna.io import open_text, read_text, write_text
@@ -304,7 +304,20 @@ def test_prediction_cache_signature_tracks_contents_not_paths(tmp_path):
304304
assert intarna.prediction_signature(tmp_path, "target.fa", "query.fa") != first
305305

306306

307-
def test_report_retains_missing_comparative_pvalues(tmp_path):
307+
def test_final_result_tables_publish_missing_values_as_empty_fields(tmp_path):
308+
path = tmp_path / "CopraRNA_result.csv"
309+
path.write_text(
310+
"fdr,p.value,NC_000001,Annotation,Additional.homologs,Amount.sampled,initial_sorting\n"
311+
"NA,NA,,containsNA,NA,0,7\n"
312+
)
313+
assert homology._finalize_result_table(path) == ["initial_sorting", "7"]
314+
assert path.read_text() == (
315+
"fdr,p-value,NC_000001,Annotation,Additional homologs,Amount sampled\n"
316+
",,,containsNA,,0\n"
317+
)
318+
319+
320+
def test_web_report_publishes_missing_comparative_pvalues_as_empty_fields(tmp_path):
308321
from coprarna.webserver import prepare_webserver_output
309322
import shutil
310323

@@ -315,12 +328,16 @@ def test_report_retains_missing_comparative_pvalues(tmp_path):
315328
lines = result.read_text().splitlines()
316329
fields = lines[1].split(",")
317330
fields[:2] = ["NA", "NA"]
331+
fields[-2] = "NA"
318332
lines[1] = ",".join(fields)
319333
result.write_text("\n".join(lines) + "\n")
320334
prepare_webserver_output(result, interactions, tmp_path)
321-
assert (tmp_path / "coprarna_internal_table.csv").read_text().splitlines()[1].split(
322-
","
323-
)[1:3] == ["NA", "NA"]
335+
published = (tmp_path / "coprarna_internal_table.csv").read_text().splitlines()[
336+
1
337+
].split(",")
338+
assert published[1:3] == ["", ""]
339+
assert published[10] == ""
340+
assert "NA" not in published
324341

325342

326343
def test_all_extended_plot_pages_are_exported_as_vectors(tmp_path, monkeypatch):

0 commit comments

Comments
 (0)