mutlof 1.0.0__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mutlof
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: Continuous LoF scores from a reference DNA FASTA and a MutCode table.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -9,7 +9,7 @@ Requires-Dist: biopython>=1.81
9
9
 
10
10
  # MutLoF
11
11
 
12
- Continuous LoF scores from a reference DNA FASTA and a MutCode table. Version 1.0.0.
12
+ Continuous LoF scores from a reference DNA FASTA and a MutCode table. Version 1.0.1.
13
13
 
14
14
  ```bash
15
15
  pip install .
@@ -19,4 +19,4 @@ mutlof \
19
19
  --output scores.tsv
20
20
  ```
21
21
 
22
- `genes.fa` headers must match the `gene` column. An empty code list scores 0. The weights ship inside the package. Add `--device cuda` on a GPU.
22
+ `genes.fa` headers must match the `gene` column. A Rustaroo gene such as `tetM/tetM_0002` uses the `tetM` header, and the row's `reference_sha256` is checked against that sequence. An empty code list scores 0. The weights ship inside the package. Add `--device cuda` on a GPU.
mutlof-1.0.1/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # MutLoF
2
+
3
+ Continuous LoF scores from a reference DNA FASTA and a MutCode table. Version 1.0.1.
4
+
5
+ ```bash
6
+ pip install .
7
+ mutlof \
8
+ --reference genes.fa \
9
+ --codes mutation_codes.tsv \
10
+ --output scores.tsv
11
+ ```
12
+
13
+ `genes.fa` headers must match the `gene` column. A Rustaroo gene such as `tetM/tetM_0002` uses the `tetM` header, and the row's `reference_sha256` is checked against that sequence. An empty code list scores 0. The weights ship inside the package. Add `--device cuda` on a GPU.
@@ -1,6 +1,6 @@
1
1
  """MutLoF: continuous LoF scores from reference sequences and MutCodes."""
2
2
 
3
- __version__ = "1.0.0"
3
+ __version__ = "1.0.1"
4
4
 
5
5
  from mutlof.model import load_model
6
6
  from mutlof.score import score_table
@@ -1,4 +1,4 @@
1
- """Command line for MutLoF 1.0.0."""
1
+ """Command line for MutLoF 1.0.1."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -89,6 +89,25 @@ def read_fasta(path: str | Path) -> dict[str, str]:
89
89
  return sequences
90
90
 
91
91
 
92
+ def reference_dna(gene: str, sequences: dict[str, str]) -> str:
93
+ """DNA for a MutCode gene name.
94
+
95
+ An exact FASTA header wins. Rustaroo stores ``family/sequence_id`` in the
96
+ gene column and the family name in the FASTA header, so otherwise the
97
+ longest ``/``-separated prefix that is a header is used.
98
+ """
99
+ if gene in sequences:
100
+ return sequences[gene]
101
+ prefix = gene
102
+ while True:
103
+ prefix, separator, _member = prefix.rpartition("/")
104
+ if not separator:
105
+ break
106
+ if prefix in sequences:
107
+ return sequences[prefix]
108
+ raise KeyError(gene)
109
+
110
+
92
111
  def read_code_table(path: str | Path) -> list[dict[str, str]]:
93
112
  """MutCode TSV or a LoF matrix. Gzip is accepted."""
94
113
  import gzip
@@ -7,7 +7,14 @@ from pathlib import Path
7
7
 
8
8
  import torch
9
9
 
10
- from mutlof.codes import apply_edits, parse_codes, read_code_table, read_fasta, sha256_seq
10
+ from mutlof.codes import (
11
+ apply_edits,
12
+ parse_codes,
13
+ read_code_table,
14
+ read_fasta,
15
+ reference_dna,
16
+ sha256_seq,
17
+ )
11
18
  from mutlof.model import LoFModel, load_model
12
19
  from mutlof.proteins import protein_features, translate_dna
13
20
  from mutlof.tokens import encode_protein, featurize_dna
@@ -51,9 +58,10 @@ def score_table(
51
58
  prepared: list[dict[str, torch.Tensor] | None] = []
52
59
  for row in rows:
53
60
  gene = row["gene"]
54
- if gene not in sequences:
55
- raise KeyError(f"{gene} is not in {reference_fasta}")
56
- reference = sequences[gene]
61
+ try:
62
+ reference = reference_dna(gene, sequences)
63
+ except KeyError:
64
+ raise KeyError(f"{gene} is not in {reference_fasta}") from None
57
65
  digest = row["reference_sha256"]
58
66
  if digest and sha256_seq(reference) != digest.lower():
59
67
  raise ValueError(f"{gene}: reference FASTA does not match reference_sha256")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mutlof
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: Continuous LoF scores from a reference DNA FASTA and a MutCode table.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -9,7 +9,7 @@ Requires-Dist: biopython>=1.81
9
9
 
10
10
  # MutLoF
11
11
 
12
- Continuous LoF scores from a reference DNA FASTA and a MutCode table. Version 1.0.0.
12
+ Continuous LoF scores from a reference DNA FASTA and a MutCode table. Version 1.0.1.
13
13
 
14
14
  ```bash
15
15
  pip install .
@@ -19,4 +19,4 @@ mutlof \
19
19
  --output scores.tsv
20
20
  ```
21
21
 
22
- `genes.fa` headers must match the `gene` column. An empty code list scores 0. The weights ship inside the package. Add `--device cuda` on a GPU.
22
+ `genes.fa` headers must match the `gene` column. A Rustaroo gene such as `tetM/tetM_0002` uses the `tetM` header, and the row's `reference_sha256` is checked against that sequence. An empty code list scores 0. The weights ship inside the package. Add `--device cuda` on a GPU.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "mutlof"
7
- version = "1.0.0"
7
+ version = "1.0.1"
8
8
  description = "Continuous LoF scores from a reference DNA FASTA and a MutCode table."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
mutlof-1.0.0/README.md DELETED
@@ -1,13 +0,0 @@
1
- # MutLoF
2
-
3
- Continuous LoF scores from a reference DNA FASTA and a MutCode table. Version 1.0.0.
4
-
5
- ```bash
6
- pip install .
7
- mutlof \
8
- --reference genes.fa \
9
- --codes mutation_codes.tsv \
10
- --output scores.tsv
11
- ```
12
-
13
- `genes.fa` headers must match the `gene` column. An empty code list scores 0. The weights ship inside the package. Add `--device cuda` on a GPU.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes