Skip to content

Commit e646e22

Browse files
committed
refactoring/linting
1 parent 170537f commit e646e22

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

ms2query/database/spec_to_compound_mapper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class SpecToCompoundMap:
2727
sqlite_path: str
2828
table: str = "spec_to_comp"
2929
compound_table: str = "compounds"
30+
3031
_conn: sqlite3.Connection = field(init=False, repr=False)
3132

3233
def __post_init__(self):
@@ -84,6 +85,8 @@ def link_many(self, pairs: Iterable[Tuple[int, str]]):
8485
cur.execute("ROLLBACK")
8586
raise
8687

88+
# ---- getters: spec_id -> comp_id ----
89+
8790
def get_comp_id_for_specs(self, spec_ids: List[str]) -> pd.DataFrame:
8891
"""Return a DataFrame with columns [spec_id, comp_id] for the provided spec_ids."""
8992
if not spec_ids:

ms2query/database/spectral_database.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,6 @@ def get_embeddings(
390390
X = X / n
391391
return np.asarray(sids, dtype=object), X
392392

393-
def get_embedding_for_id(
394-
self,
395-
spec_id: str,
396-
*,
397-
embeddings_table: str = "embeddings",
398-
normalized: bool = True,
399-
) -> Optional[np.ndarray]:
400-
ids, X = self.get_embeddings([spec_id], embeddings_table=embeddings_table, normalized=normalized)
401-
return X[0] if X.shape[0] else None
402-
403393
# expose raw connection for ANN builders
404394
@property
405395
def connection(self) -> sqlite3.Connection:

ms2query/ms2query_library.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ class MS2QueryLibrary:
2626
2727
Notes
2828
-----
29-
* `model_path` is optional; provide it if you want on-the-fly embedding of ad-hoc spectra.
30-
If omitted, you can still query using precomputed embeddings fetched from SQLite.
3129
* EmbeddingIndex must be built/loaded elsewhere (creation handled by setup workflow).
3230
"""
3331
db: MS2QueryDatabase
@@ -221,7 +219,16 @@ def query_compounds_by_compounds(
221219
]
222220
results_all.append(one)
223221

224-
return results_all
222+
# Convert to DataFrame
223+
results_df = pd.DataFrame(
224+
[
225+
{"query_ix": qi, **item}
226+
for qi, lst in enumerate(results_all)
227+
for item in lst
228+
],
229+
columns=["query_ix", "rank", "comp_id", "score"],
230+
)
231+
return results_df
225232

226233
def query_compounds_by_spectra(
227234
self,

0 commit comments

Comments
 (0)