madrigal-predictor 0.1.0__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.
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2026 Staller Lab
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: madrigal-predictor
3
+ Version: 0.1.0
4
+ Summary: Consensus model package that predicts the section in an amino acid sequence likely to be a transcription factor, based on the consensus model created at Staller Lab, according to a given particular threshold or a generic threshold of 0.7.
5
+ Author-email: Claire Josephine LeBlanc <claire.leblanc@berkeley.edu>, Marissa Ann Zintel <marissa.zintel@berkeley.edu>, "Sanjana R. Kotha" <sanjana.kotha@berkeley.edu>, Rishaan Jayce Bansal <ruhi.bansal@berkeley.edu>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/staller-lab/consensus_model_package
8
+ Project-URL: Issues, https://github.com/staller-lab/consensus_model_package/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: <3.12,>=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: idptools-parrot
15
+ Requires-Dist: numpy
16
+ Requires-Dist: torch
17
+ Dynamic: license-file
18
+
19
+ This is a Python package that is based off of the MADRIGAL consensus activation-domain predictor model developed at Staller Lab.
20
+
21
+ Credits to Holehouse Lab for development and use of the Parrot package to analyze amino acid data in protein sequences: github.com/idptools/parrot
22
+
23
+ Developed by Staller Lab. Credits to Claire Josephine LeBlanc, Marissa Ann Zintel, Sanjana R. Kotha, Rishaan J. Bansal.
24
+ https://www.stallerlab.com/
25
+
26
+ Example Usage:
27
+ ```
28
+ import madrigal_predictor as mp # import the madrigal predictor
29
+ import os
30
+
31
+ path_fasta = os.path.expanduser("~/Documents/example_fasta.fasta")
32
+
33
+ # Example: Read a string sequence - outputs likely ADs, unlikely ADs, list of start coordinates, list of end coordinates
34
+ ADs, not_ADs, starts, ends = mp.read_sequence("MSEYQPSLFALNPMGFSPLDGSKSTNENVSASTSTAKPMVGQLIFDKFIKTEEDPIIKQDTPSNLDFDFALPQTATAPDAKTVLPIPELDDAVVESFFSSSTDSTPMFEYENLEDNSKEWTSLFDNDIPVTTDDVSLADKAIESTEEVSLVPSNLEVSTTSFLPTPVLEDAKLTQTRKVKKPNSVVKKSHHVGKDDESRLDHLGVVAYNRKQRSIPLSPIVPESSDPAALKRARNTEAARRSRARKLQRMKQLEDKVEELLSKNYHLENEVARLKKLVGER", threshold=0.8)
35
+
36
+ # Example: Reads a fasta file given a path, outputs lists of titles, likely ADs
37
+ titles, all_ADs, all_nots, all_starts, all_ends = mp.analyze_fasta_file(path_fasta, threshold=0.8)
38
+ ```
39
+
@@ -0,0 +1,21 @@
1
+ This is a Python package that is based off of the MADRIGAL consensus activation-domain predictor model developed at Staller Lab.
2
+
3
+ Credits to Holehouse Lab for development and use of the Parrot package to analyze amino acid data in protein sequences: github.com/idptools/parrot
4
+
5
+ Developed by Staller Lab. Credits to Claire Josephine LeBlanc, Marissa Ann Zintel, Sanjana R. Kotha, Rishaan J. Bansal.
6
+ https://www.stallerlab.com/
7
+
8
+ Example Usage:
9
+ ```
10
+ import madrigal_predictor as mp # import the madrigal predictor
11
+ import os
12
+
13
+ path_fasta = os.path.expanduser("~/Documents/example_fasta.fasta")
14
+
15
+ # Example: Read a string sequence - outputs likely ADs, unlikely ADs, list of start coordinates, list of end coordinates
16
+ ADs, not_ADs, starts, ends = mp.read_sequence("MSEYQPSLFALNPMGFSPLDGSKSTNENVSASTSTAKPMVGQLIFDKFIKTEEDPIIKQDTPSNLDFDFALPQTATAPDAKTVLPIPELDDAVVESFFSSSTDSTPMFEYENLEDNSKEWTSLFDNDIPVTTDDVSLADKAIESTEEVSLVPSNLEVSTTSFLPTPVLEDAKLTQTRKVKKPNSVVKKSHHVGKDDESRLDHLGVVAYNRKQRSIPLSPIVPESSDPAALKRARNTEAARRSRARKLQRMKQLEDKVEELLSKNYHLENEVARLKKLVGER", threshold=0.8)
17
+
18
+ # Example: Reads a fasta file given a path, outputs lists of titles, likely ADs
19
+ titles, all_ADs, all_nots, all_starts, all_ends = mp.analyze_fasta_file(path_fasta, threshold=0.8)
20
+ ```
21
+
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "madrigal-predictor"
3
+ version = "0.1.0"
4
+ dependencies = [
5
+ "idptools-parrot",
6
+ "numpy",
7
+ "torch",
8
+ ]
9
+ authors = [
10
+ { name="Claire Josephine LeBlanc", email="claire.leblanc@berkeley.edu" },
11
+ { name="Marissa Ann Zintel", email="marissa.zintel@berkeley.edu" },
12
+ { name="Sanjana R. Kotha", email="sanjana.kotha@berkeley.edu"},
13
+ { name="Rishaan Jayce Bansal", email="ruhi.bansal@berkeley.edu" },
14
+ ]
15
+ description = "Consensus model package that predicts the section in an amino acid sequence likely to be a transcription factor, based on the consensus model created at Staller Lab, according to a given particular threshold or a generic threshold of 0.7."
16
+ readme = "README.md"
17
+ requires-python = ">=3.9, <3.12"
18
+ classifiers = [
19
+ "Programming Language :: Python :: 3",
20
+ "Operating System :: OS Independent",
21
+ ]
22
+ license = "MIT"
23
+ license-files = ["LICEN[CS]E*"]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/staller-lab/consensus_model_package"
27
+ Issues = "https://github.com/staller-lab/consensus_model_package/issues"
28
+
29
+ [tool.setuptools.package-data]
30
+ madrigal_predictor = ["*.pt"]
31
+
32
+ [tool.hatch.build.targets.wheel]
33
+ include = ["src/madrigal_predictor"]
34
+ artifacts = ["src/madrigal_predictor/*.pt"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ from .package_script import read_sequence, analyze_fasta_file
2
+ from importlib.metadata import version
3
+
4
+ __all__ = ["read_sequence", "analyze_fasta_file"]
5
+
6
+ __version__ = version("madrigal-predictor")
7
+
@@ -0,0 +1,86 @@
1
+ import argparse
2
+ from pathlib import Path
3
+ from parrot import encode_sequence
4
+ from madrigal_predictor.run_query import run
5
+ from madrigal_predictor.process_runs import get_runs, get_runs_coords
6
+
7
+ def analyze_fasta_file(file_path: str | Path, threshold: float = 0.6):
8
+ """
9
+ Reads protein sequences of amino acids from FASTA File.
10
+
11
+ Args:
12
+ file_path: path to FASTA file (str or path)
13
+ threshold: the threshold of likeliness for a protein sequence to be an AD
14
+
15
+ Returns:
16
+ titles: a list of the titles of the FASTA proteins
17
+ above_runs: a list of lists, with inner lists having protein sequences likely to be ADs
18
+ below_runs: a list of lists, with inner lists having protein sequences unlikely to be ADs
19
+ above_starts: a list of lists, with inner lists having coordinates of starts of likely ADs
20
+ below_starts: a list of lists, with inner lists having coordinates of ends of likely ADs
21
+
22
+ """
23
+ # Read file path
24
+ contents = Path(file_path).read_text(encoding='utf-8')
25
+ return read_sequences(contents, threshold)
26
+
27
+
28
+ def read_sequence(data: str, threshold: float = 0.6):
29
+ """Reads a protein sequence (string) of amino acids and analyzes what is likely an AD
30
+
31
+ Args:
32
+ data: protein sequence to be analyzed, represented by amino acids
33
+ threshold: the threshold of a likeliness for a protein sequence to be an AD
34
+
35
+ Returns:
36
+ above_runs: list having protein sequences likely to be ADs
37
+ below_runs: list having protein sequences unlikely to be ADs
38
+ above_starts: list having coordinates of starts of likely ADs
39
+ below_starts: list having coordinates of ends of likely ADs
40
+
41
+ """
42
+ data = sanitize(data)
43
+ query_input = encode_sequence.one_hot(data).float().unsqueeze(0)
44
+ output = run(query_input).squeeze().tolist()
45
+ sequence = ''.join(data.upper().split())
46
+ above_runs, below_runs, above_starts, below_starts= get_runs_coords(sequence, output, threshold)
47
+ return above_runs, below_runs, above_starts, below_starts
48
+
49
+ def sanitize(sequence):
50
+ return ''.join(sequence.upper().split())
51
+
52
+ def read_sequences(data, threshold=0.6):
53
+ lines = data.splitlines()
54
+
55
+ titles = []
56
+ above_runs = []
57
+ below_runs = []
58
+ above_starts = []
59
+ below_starts = []
60
+
61
+ seq = ''
62
+ for line in lines:
63
+ if line.startswith('>'):
64
+ if seq != '':
65
+ seq = sanitize(seq)
66
+ above_run, below_run, above_start, below_start = read_sequence(seq, threshold)
67
+ above_runs.append(above_run)
68
+ below_runs.append(below_run)
69
+ above_starts.append(above_start)
70
+ below_starts.append(below_start)
71
+ seq = ''
72
+ titles.append(line[1:])
73
+ else:
74
+ seq += line
75
+
76
+ if seq != '':
77
+ seq = sanitize(seq)
78
+ above_run, below_run, above_start, below_start = read_sequence(seq, threshold)
79
+ above_runs.append(above_run)
80
+ below_runs.append(below_run)
81
+ above_starts.append(above_start)
82
+ below_starts.append(below_start)
83
+ seq = ''
84
+
85
+
86
+ return titles, above_runs, below_runs, above_starts, below_starts
@@ -0,0 +1,64 @@
1
+ def get_runs(sequence, output, threshold):
2
+ """Return contiguous runs of residues above and below threshold."""
3
+ above_runs = []
4
+ below_runs = []
5
+
6
+ current_above = ''
7
+ current_below = ''
8
+
9
+ for aa, val in zip(sequence, output):
10
+ if threshold is None or val >= float(threshold):
11
+ current_above += aa
12
+ if current_below:
13
+ below_runs.append(current_below)
14
+ current_below = ''
15
+ else:
16
+ current_below += aa
17
+ if current_above:
18
+ above_runs.append(current_above)
19
+ current_above = ''
20
+
21
+ # flush last run
22
+ if current_above:
23
+ above_runs.append(current_above)
24
+ if current_below:
25
+ below_runs.append(current_below)
26
+
27
+ return above_runs, below_runs
28
+
29
+ def get_runs_coords(sequence, output, threshold):
30
+ """Return contiguous runs of residues above and below threshold, and the coordinates of the transitions above and below the threshold"""
31
+
32
+ above_runs = []
33
+ below_runs = []
34
+ starts_above = []
35
+ starts_below = []
36
+
37
+ current_above = ''
38
+ current_below = ''
39
+
40
+ for i in range(len(sequence)):
41
+ if threshold is None or output[i] >= float(threshold):
42
+ if not current_above:
43
+ starts_above.append(i)
44
+ current_above += sequence[i]
45
+ if current_below:
46
+ below_runs.append(current_below)
47
+ current_below = ''
48
+
49
+ else:
50
+ if not current_below:
51
+ starts_below.append(i)
52
+ current_below += sequence[i]
53
+ if current_above:
54
+ above_runs.append(current_above)
55
+ current_above = ''
56
+
57
+ # flush last run
58
+ if current_above:
59
+ above_runs.append(current_above)
60
+ if current_below:
61
+ below_runs.append(current_below)
62
+
63
+
64
+ return above_runs, below_runs, starts_above, starts_below
@@ -0,0 +1,25 @@
1
+ import torch
2
+ from parrot.brnn_architecture import BRNN_MtM
3
+ from importlib.resources import files, as_file
4
+
5
+ # Select your hardware device (GPU if available, otherwise CPU)
6
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
7
+
8
+ model = BRNN_MtM(20, hidden_size=10, num_layers=1, num_classes=1, device=device)
9
+
10
+ weights = files("madrigal_predictor") / "consensus_model_all_six.pt"
11
+ with as_file(weights) as model_path:
12
+ state = torch.load(model_path, map_location=device, weights_only=True) # Best practice: use weights_only=True for security when unpickling
13
+ model.load_state_dict(state)
14
+ model = model.to(device)
15
+
16
+ # Set the model to evaluation mode
17
+ model.eval()
18
+
19
+ # 5. Function That Takes Input and Returns Output
20
+ def run(query_tensor):
21
+ with torch.no_grad():
22
+ predictions = model(query_tensor.to(device))
23
+ return predictions.cpu()
24
+
25
+
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: madrigal-predictor
3
+ Version: 0.1.0
4
+ Summary: Consensus model package that predicts the section in an amino acid sequence likely to be a transcription factor, based on the consensus model created at Staller Lab, according to a given particular threshold or a generic threshold of 0.7.
5
+ Author-email: Claire Josephine LeBlanc <claire.leblanc@berkeley.edu>, Marissa Ann Zintel <marissa.zintel@berkeley.edu>, "Sanjana R. Kotha" <sanjana.kotha@berkeley.edu>, Rishaan Jayce Bansal <ruhi.bansal@berkeley.edu>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/staller-lab/consensus_model_package
8
+ Project-URL: Issues, https://github.com/staller-lab/consensus_model_package/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: <3.12,>=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: idptools-parrot
15
+ Requires-Dist: numpy
16
+ Requires-Dist: torch
17
+ Dynamic: license-file
18
+
19
+ This is a Python package that is based off of the MADRIGAL consensus activation-domain predictor model developed at Staller Lab.
20
+
21
+ Credits to Holehouse Lab for development and use of the Parrot package to analyze amino acid data in protein sequences: github.com/idptools/parrot
22
+
23
+ Developed by Staller Lab. Credits to Claire Josephine LeBlanc, Marissa Ann Zintel, Sanjana R. Kotha, Rishaan J. Bansal.
24
+ https://www.stallerlab.com/
25
+
26
+ Example Usage:
27
+ ```
28
+ import madrigal_predictor as mp # import the madrigal predictor
29
+ import os
30
+
31
+ path_fasta = os.path.expanduser("~/Documents/example_fasta.fasta")
32
+
33
+ # Example: Read a string sequence - outputs likely ADs, unlikely ADs, list of start coordinates, list of end coordinates
34
+ ADs, not_ADs, starts, ends = mp.read_sequence("MSEYQPSLFALNPMGFSPLDGSKSTNENVSASTSTAKPMVGQLIFDKFIKTEEDPIIKQDTPSNLDFDFALPQTATAPDAKTVLPIPELDDAVVESFFSSSTDSTPMFEYENLEDNSKEWTSLFDNDIPVTTDDVSLADKAIESTEEVSLVPSNLEVSTTSFLPTPVLEDAKLTQTRKVKKPNSVVKKSHHVGKDDESRLDHLGVVAYNRKQRSIPLSPIVPESSDPAALKRARNTEAARRSRARKLQRMKQLEDKVEELLSKNYHLENEVARLKKLVGER", threshold=0.8)
35
+
36
+ # Example: Reads a fasta file given a path, outputs lists of titles, likely ADs
37
+ titles, all_ADs, all_nots, all_starts, all_ends = mp.analyze_fasta_file(path_fasta, threshold=0.8)
38
+ ```
39
+
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/madrigal_predictor/__init__.py
5
+ src/madrigal_predictor/consensus_model_all_six.pt
6
+ src/madrigal_predictor/package_script.py
7
+ src/madrigal_predictor/process_runs.py
8
+ src/madrigal_predictor/run_query.py
9
+ src/madrigal_predictor.egg-info/PKG-INFO
10
+ src/madrigal_predictor.egg-info/SOURCES.txt
11
+ src/madrigal_predictor.egg-info/dependency_links.txt
12
+ src/madrigal_predictor.egg-info/requires.txt
13
+ src/madrigal_predictor.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ idptools-parrot
2
+ numpy
3
+ torch
@@ -0,0 +1 @@
1
+ madrigal_predictor