spymot 2.1.1.dev0__py3-none-any.whl

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.
spymot/__init__.py ADDED
@@ -0,0 +1,103 @@
1
+ """
2
+ Spymot: Advanced Protein Motif Detection with AlphaFold Structural Validation
3
+
4
+ A comprehensive protein analysis platform that combines motif detection with 3D structure
5
+ validation using AlphaFold2 confidence scores. Designed for cancer biology research,
6
+ drug discovery, and functional genomics.
7
+
8
+ Version Information:
9
+ - V1: Original foundational system with basic motif detection
10
+ - V2: Enhanced production system with 94.6% motif coverage and advanced features
11
+
12
+ Usage:
13
+ from spymot import analyze_sequence # V1 functionality
14
+ from spymot.v2 import EnhancedSpymotAnalyzer # V2 functionality
15
+
16
+ # Basic analysis
17
+ result = analyze_sequence("p53", "MEEPQSDPSVEPPLSQETFSD...")
18
+
19
+ # Enhanced analysis
20
+ analyzer = EnhancedSpymotAnalyzer()
21
+ result = analyzer.analyze_sequence_comprehensive("p53", "MEEPQSDPSVEPPLSQETFSD...")
22
+ """
23
+
24
+ from ._version import __version__
25
+
26
+ # V1 Imports (Original functionality)
27
+ try:
28
+ from .v1.analyzer import analyze_sequence, analyze_by_pdb
29
+ from .v1.motifs import scan_motifs, get_motif_statistics
30
+ from .v1.targeting import predict_targeting
31
+ from .v1.afdb import get_prediction_meta, fetch_pdb_text, mean_plddt_over_region
32
+ from .v1.utils import read_fasta, validate_sequence
33
+
34
+ __all_v1__ = [
35
+ "analyze_sequence",
36
+ "analyze_by_pdb",
37
+ "scan_motifs",
38
+ "get_motif_statistics",
39
+ "predict_targeting",
40
+ "get_prediction_meta",
41
+ "fetch_pdb_text",
42
+ "mean_plddt_over_region",
43
+ "read_fasta",
44
+ "validate_sequence"
45
+ ]
46
+ except ImportError:
47
+ __all_v1__ = []
48
+
49
+ # V2 Imports (Enhanced functionality)
50
+ try:
51
+ from .v2.enhanced_analyzer import EnhancedSpymotAnalyzer
52
+ from .v2.context_aware_detector import ContextAwareDetector
53
+ from .v2.enhanced_motifs_db import EnhancedMotifDatabase
54
+
55
+ __all_v2__ = [
56
+ "EnhancedSpymotAnalyzer",
57
+ "ContextAwareDetector",
58
+ "EnhancedMotifDatabase"
59
+ ]
60
+ except ImportError:
61
+ __all_v2__ = []
62
+
63
+ # Main exports (V1 for backward compatibility)
64
+ __all__ = [
65
+ "__version__",
66
+ # V1 exports
67
+ "analyze_sequence",
68
+ "analyze_by_pdb",
69
+ "scan_motifs",
70
+ "get_motif_statistics",
71
+ "predict_targeting",
72
+ "read_fasta",
73
+ "validate_sequence",
74
+ # V2 exports
75
+ "EnhancedSpymotAnalyzer",
76
+ "ContextAwareDetector",
77
+ "EnhancedMotifDatabase"
78
+ ]
79
+
80
+ # Package metadata
81
+ __author__ = "Erfan Zohrabi"
82
+ __email__ = "erfanzohrabi.ez@gmail.com"
83
+ __description__ = "Advanced Protein Motif Detection with AlphaFold Structural Validation"
84
+ __url__ = "https://github.com/ErfanZohrabi/Spymot"
85
+ __license__ = "MIT"
86
+
87
+ # Version info
88
+ def get_version():
89
+ """Get the current version of Spymot."""
90
+ return __version__
91
+
92
+ def get_version_info():
93
+ """Get detailed version information."""
94
+ return {
95
+ "version": __version__,
96
+ "author": __author__,
97
+ "email": __email__,
98
+ "description": __description__,
99
+ "url": __url__,
100
+ "license": __license__,
101
+ "v1_available": len(__all_v1__) > 0,
102
+ "v2_available": len(__all_v2__) > 0
103
+ }
spymot/_version.py ADDED
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '2.1.1.dev0'
32
+ __version_tuple__ = version_tuple = (2, 1, 1, 'dev0')
33
+
34
+ __commit_id__ = commit_id = None
spymot/cli.py ADDED
@@ -0,0 +1,160 @@
1
+ """
2
+ Main command-line interface for Spymot package.
3
+ Provides unified access to both V1 and V2 functionality.
4
+ """
5
+
6
+ import click
7
+ import sys
8
+ from pathlib import Path
9
+ from typing import Optional
10
+
11
+ from ._version import __version__
12
+
13
+ @click.group(context_settings={'help_option_names': ['-h', '--help']})
14
+ @click.version_option(__version__, '-v', '--version')
15
+ def main():
16
+ """
17
+ 🧬 Spymot - Advanced Protein Motif Detection with AlphaFold Structural Validation
18
+
19
+ A comprehensive protein analysis platform for cancer biology research,
20
+ drug discovery, and functional genomics.
21
+
22
+ Choose your version:
23
+ • V1: Original foundational system with basic motif detection
24
+ • V2: Enhanced production system with 94.6% motif coverage
25
+
26
+ Examples:
27
+ spymot v1 analyze protein.fasta --format json
28
+ spymot v2 analyze protein.fasta --database all --cancer-only
29
+ spymot interactive
30
+ """
31
+ pass
32
+
33
+ @main.group()
34
+ def v1():
35
+ """V1: Original Spymot functionality (basic motif detection)"""
36
+ pass
37
+
38
+ @main.group()
39
+ def v2():
40
+ """V2: Enhanced Spymot functionality (comprehensive analysis)"""
41
+ pass
42
+
43
+ @main.command()
44
+ @click.option('--version', 'version_choice',
45
+ type=click.Choice(['v1', 'v2']),
46
+ default='v2',
47
+ help='Choose Spymot version')
48
+ def interactive(version_choice: str):
49
+ """Launch interactive analysis mode"""
50
+ try:
51
+ if version_choice == 'v1':
52
+ from .v1.cli import interactive as v1_interactive
53
+ v1_interactive()
54
+ else:
55
+ from .v2.scripts.interactive_cli import main as v2_interactive
56
+ v2_interactive()
57
+ except ImportError as e:
58
+ click.echo(f"❌ Error: {e}", err=True)
59
+ click.echo(f"Make sure {version_choice} is properly installed.", err=True)
60
+ sys.exit(1)
61
+
62
+ @v1.command()
63
+ @click.argument('input_file', type=click.Path(exists=True, path_type=Path))
64
+ @click.option('--id', 'uniprot_id', help='UniProt ID hint for structure mapping')
65
+ @click.option('-o', '--output', type=click.Path(path_type=Path), help='Output file path')
66
+ @click.option('--format', 'output_format', default='json',
67
+ type=click.Choice(['json', 'yaml', 'txt']), help='Output format')
68
+ @click.option('--database', 'motif_db_type', default='all',
69
+ type=click.Choice(['all', 'cancer', 'signals', 'hardcoded']),
70
+ help='Which motif databases to use')
71
+ @click.option('--verbose', '-v', is_flag=True, help='Verbose output')
72
+ def analyze(input_file: Path, uniprot_id: Optional[str], output: Optional[Path],
73
+ output_format: str, motif_db_type: str, verbose: bool):
74
+ """Analyze protein sequence using V1 functionality"""
75
+ try:
76
+ from .v1.cli import analyze as v1_analyze
77
+ v1_analyze(input_file, uniprot_id, output, output_format, True, False, 0.0, motif_db_type, False, verbose)
78
+ except ImportError as e:
79
+ click.echo(f"❌ Error: V1 functionality not available: {e}", err=True)
80
+ sys.exit(1)
81
+
82
+ @v1.command()
83
+ @click.argument('pdb_id', type=str)
84
+ @click.option('-o', '--output', type=click.Path(path_type=Path), help='Output file path')
85
+ @click.option('--format', 'output_format', default='json',
86
+ type=click.Choice(['json', 'yaml', 'txt']), help='Output format')
87
+ @click.option('--verbose', '-v', is_flag=True, help='Verbose output')
88
+ def pdb(pdb_id: str, output: Optional[Path], output_format: str, verbose: bool):
89
+ """Analyze protein by PDB structure ID using V1 functionality"""
90
+ try:
91
+ from .v1.cli import pdb as v1_pdb
92
+ v1_pdb(pdb_id, output, output_format, verbose)
93
+ except ImportError as e:
94
+ click.echo(f"❌ Error: V1 functionality not available: {e}", err=True)
95
+ sys.exit(1)
96
+
97
+ @v2.command()
98
+ @click.argument('input_file', type=click.Path(exists=True, path_type=Path))
99
+ @click.option('--id', 'uniprot_id', help='UniProt ID hint for structure mapping')
100
+ @click.option('-o', '--output', type=click.Path(path_type=Path), help='Output file path')
101
+ @click.option('--format', 'output_format', default='json',
102
+ type=click.Choice(['json', 'yaml', 'txt']), help='Output format')
103
+ @click.option('--database', 'motif_db_type', default='all',
104
+ type=click.Choice(['all', 'cancer', 'signals', 'hardcoded']),
105
+ help='Which motif databases to use')
106
+ @click.option('--cancer-only', is_flag=True, help='Show only cancer-relevant motifs')
107
+ @click.option('--min-confidence', type=float, default=0.0,
108
+ help='Minimum confidence threshold (0.0-1.0)')
109
+ @click.option('--verbose', '-v', is_flag=True, help='Verbose output')
110
+ def analyze(input_file: Path, uniprot_id: Optional[str], output: Optional[Path],
111
+ output_format: str, motif_db_type: str, cancer_only: bool,
112
+ min_confidence: float, verbose: bool):
113
+ """Analyze protein sequence using V2 enhanced functionality"""
114
+ try:
115
+ from .v2.scripts.enhanced_cli import analyze as v2_analyze
116
+ v2_analyze(input_file, uniprot_id, output, output_format, motif_db_type,
117
+ cancer_only, min_confidence, verbose)
118
+ except ImportError as e:
119
+ click.echo(f"❌ Error: V2 functionality not available: {e}", err=True)
120
+ sys.exit(1)
121
+
122
+ @v2.command()
123
+ @click.option('--format', 'output_format', default='txt',
124
+ type=click.Choice(['json', 'yaml', 'txt']), help='Output format')
125
+ @click.option('--verbose', '-v', is_flag=True, help='Verbose output')
126
+ def databases(output_format: str, verbose: bool):
127
+ """Show information about available motif databases (V2)"""
128
+ try:
129
+ from .v2.scripts.enhanced_cli import databases as v2_databases
130
+ v2_databases(output_format, verbose)
131
+ except ImportError as e:
132
+ click.echo(f"❌ Error: V2 functionality not available: {e}", err=True)
133
+ sys.exit(1)
134
+
135
+ @main.command()
136
+ def info():
137
+ """Show package information and version details"""
138
+ from . import get_version_info
139
+
140
+ info = get_version_info()
141
+
142
+ click.echo("🧬 SPYMOT PACKAGE INFORMATION")
143
+ click.echo("=" * 50)
144
+ click.echo(f"Version: {info['version']}")
145
+ click.echo(f"Author: {info['author']}")
146
+ click.echo(f"Description: {info['description']}")
147
+ click.echo(f"License: {info['license']}")
148
+ click.echo(f"URL: {info['url']}")
149
+ click.echo()
150
+ click.echo("Available Components:")
151
+ click.echo(f" • V1 (Original): {'✅ Available' if info['v1_available'] else '❌ Not Available'}")
152
+ click.echo(f" • V2 (Enhanced): {'✅ Available' if info['v2_available'] else '❌ Not Available'}")
153
+ click.echo()
154
+ click.echo("Usage Examples:")
155
+ click.echo(" spymot v1 analyze protein.fasta --format json")
156
+ click.echo(" spymot v2 analyze protein.fasta --database all --cancer-only")
157
+ click.echo(" spymot interactive --version v2")
158
+
159
+ if __name__ == '__main__':
160
+ main()
spymot/v1/__init__.py ADDED
@@ -0,0 +1,50 @@
1
+ """
2
+ Spymot V1: Original foundational protein motif detection system.
3
+
4
+ This module provides access to the original Spymot functionality including:
5
+ - Basic motif detection
6
+ - AlphaFold integration
7
+ - Simple CLI interface
8
+ - Core motif database
9
+ """
10
+
11
+ # Import V1 modules from the actual V1 directory
12
+ import sys
13
+ from pathlib import Path
14
+
15
+ # Add V1 directory to path for imports
16
+ v1_path = Path(__file__).parent.parent.parent.parent / "V1"
17
+ if str(v1_path) not in sys.path:
18
+ sys.path.insert(0, str(v1_path))
19
+
20
+ try:
21
+ # Import V1 modules
22
+ from spymot.analyzer import analyze_sequence, analyze_by_pdb
23
+ from spymot.motifs import scan_motifs, get_motif_statistics
24
+ from spymot.targeting import predict_targeting
25
+ from spymot.afdb import get_prediction_meta, fetch_pdb_text, mean_plddt_over_region
26
+ from spymot.utils import read_fasta, validate_sequence
27
+ from spymot.cli import main as cli_main, interactive
28
+
29
+ __all__ = [
30
+ "analyze_sequence",
31
+ "analyze_by_pdb",
32
+ "scan_motifs",
33
+ "get_motif_statistics",
34
+ "predict_targeting",
35
+ "get_prediction_meta",
36
+ "fetch_pdb_text",
37
+ "mean_plddt_over_region",
38
+ "read_fasta",
39
+ "validate_sequence",
40
+ "cli_main",
41
+ "interactive"
42
+ ]
43
+
44
+ V1_AVAILABLE = True
45
+
46
+ except ImportError as e:
47
+ # V1 not available
48
+ __all__ = []
49
+ V1_AVAILABLE = False
50
+ V1_ERROR = str(e)
spymot/v1/cli.py ADDED
@@ -0,0 +1,32 @@
1
+ """
2
+ V1 CLI wrapper for original Spymot functionality.
3
+ """
4
+
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ # Add V1 directory to path
9
+ v1_path = Path(__file__).parent.parent.parent.parent.parent / "V1"
10
+ if str(v1_path) not in sys.path:
11
+ sys.path.insert(0, str(v1_path))
12
+
13
+ def main():
14
+ """Main entry point for V1 CLI."""
15
+ try:
16
+ from spymot.cli import main as v1_main
17
+ v1_main()
18
+ except ImportError as e:
19
+ print(f"❌ Error: V1 CLI not available: {e}", file=sys.stderr)
20
+ sys.exit(1)
21
+
22
+ def interactive():
23
+ """Interactive mode for V1."""
24
+ try:
25
+ from spymot.cli import interactive as v1_interactive
26
+ v1_interactive()
27
+ except ImportError as e:
28
+ print(f"❌ Error: V1 interactive mode not available: {e}", file=sys.stderr)
29
+ sys.exit(1)
30
+
31
+ if __name__ == '__main__':
32
+ main()
spymot/v2/__init__.py ADDED
@@ -0,0 +1,47 @@
1
+ """
2
+ Spymot V2: Enhanced protein motif detection system.
3
+
4
+ This module provides access to the enhanced Spymot functionality including:
5
+ - 94.6% motif coverage (316+ patterns)
6
+ - Context-aware detection
7
+ - Advanced cancer relevance scoring
8
+ - Rich JSON output with biological interpretation
9
+ - Production-ready features
10
+ """
11
+
12
+ # Import V2 modules from the actual V2 directory
13
+ import sys
14
+ from pathlib import Path
15
+
16
+ # Add V2 directory to path for imports
17
+ v2_path = Path(__file__).parent.parent.parent.parent / "V2"
18
+ if str(v2_path) not in sys.path:
19
+ sys.path.insert(0, str(v2_path))
20
+
21
+ try:
22
+ # Import V2 modules
23
+ from enhanced_analyzer import EnhancedSpymotAnalyzer
24
+ from context_aware_detector import ContextAwareDetector
25
+ from enhanced_motifs_db import EnhancedMotifDatabase
26
+
27
+ # Import scripts
28
+ from scripts.enhanced_cli import main as enhanced_cli_main
29
+ from scripts.enhanced_demo import main as demo_main
30
+ from scripts.interactive_cli import main as interactive_main
31
+
32
+ __all__ = [
33
+ "EnhancedSpymotAnalyzer",
34
+ "ContextAwareDetector",
35
+ "EnhancedMotifDatabase",
36
+ "enhanced_cli_main",
37
+ "demo_main",
38
+ "interactive_main"
39
+ ]
40
+
41
+ V2_AVAILABLE = True
42
+
43
+ except ImportError as e:
44
+ # V2 not available
45
+ __all__ = []
46
+ V2_AVAILABLE = False
47
+ V2_ERROR = str(e)
@@ -0,0 +1,6 @@
1
+ """
2
+ Spymot V2 Scripts: Command-line interfaces for enhanced functionality.
3
+ """
4
+
5
+ # This module provides access to V2 CLI scripts
6
+ # The actual scripts are imported from the V2 directory
@@ -0,0 +1,43 @@
1
+ """
2
+ Enhanced CLI wrapper for V2 functionality.
3
+ """
4
+
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ # Add V2 directory to path
9
+ v2_path = Path(__file__).parent.parent.parent.parent.parent / "V2"
10
+ if str(v2_path) not in sys.path:
11
+ sys.path.insert(0, str(v2_path))
12
+
13
+ def main():
14
+ """Main entry point for enhanced CLI."""
15
+ try:
16
+ from scripts.enhanced_cli import main as v2_main
17
+ v2_main()
18
+ except ImportError as e:
19
+ print(f"❌ Error: V2 enhanced CLI not available: {e}", file=sys.stderr)
20
+ sys.exit(1)
21
+
22
+ def analyze(input_file, uniprot_id=None, output=None, output_format='json',
23
+ motif_db_type='all', cancer_only=False, min_confidence=0.0, verbose=False):
24
+ """Analyze protein sequence using V2 enhanced functionality."""
25
+ try:
26
+ from scripts.enhanced_cli import analyze as v2_analyze
27
+ v2_analyze(input_file, uniprot_id, output, output_format, motif_db_type,
28
+ cancer_only, min_confidence, verbose)
29
+ except ImportError as e:
30
+ print(f"❌ Error: V2 enhanced analysis not available: {e}", file=sys.stderr)
31
+ sys.exit(1)
32
+
33
+ def databases(output_format='txt', verbose=False):
34
+ """Show database information."""
35
+ try:
36
+ from scripts.enhanced_cli import databases as v2_databases
37
+ v2_databases(output_format, verbose)
38
+ except ImportError as e:
39
+ print(f"❌ Error: V2 database info not available: {e}", file=sys.stderr)
40
+ sys.exit(1)
41
+
42
+ if __name__ == '__main__':
43
+ main()
@@ -0,0 +1,23 @@
1
+ """
2
+ Enhanced demo wrapper for V2 functionality.
3
+ """
4
+
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ # Add V2 directory to path
9
+ v2_path = Path(__file__).parent.parent.parent.parent.parent / "V2"
10
+ if str(v2_path) not in sys.path:
11
+ sys.path.insert(0, str(v2_path))
12
+
13
+ def main():
14
+ """Main entry point for enhanced demo."""
15
+ try:
16
+ from scripts.enhanced_demo import main as v2_demo
17
+ v2_demo()
18
+ except ImportError as e:
19
+ print(f"❌ Error: V2 enhanced demo not available: {e}", file=sys.stderr)
20
+ sys.exit(1)
21
+
22
+ if __name__ == '__main__':
23
+ main()
@@ -0,0 +1,23 @@
1
+ """
2
+ Interactive CLI wrapper for V2 functionality.
3
+ """
4
+
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ # Add V2 directory to path
9
+ v2_path = Path(__file__).parent.parent.parent.parent.parent / "V2"
10
+ if str(v2_path) not in sys.path:
11
+ sys.path.insert(0, str(v2_path))
12
+
13
+ def main():
14
+ """Main entry point for interactive CLI."""
15
+ try:
16
+ from scripts.interactive_cli import main as v2_interactive
17
+ v2_interactive()
18
+ except ImportError as e:
19
+ print(f"❌ Error: V2 interactive CLI not available: {e}", file=sys.stderr)
20
+ sys.exit(1)
21
+
22
+ if __name__ == '__main__':
23
+ main()