DeepMutSim 1.0.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Liu Sun
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: DeepMutSim
3
+ Version: 1.0.0
4
+ Summary: Generates all possible SNVs for MANE transcripts using HGVS nomenclature.
5
+ Author-email: Liu Sun <sunliu@yxnu.edu.cn>, Jian Yang <yangjian@yxnu.edu.cn>
6
+ Project-URL: Homepage, https://github.com/liu-sun/DeepMutSim
7
+ Project-URL: Issues, https://github.com/liu-sun/DeepMutSim/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: biopython
15
+ Dynamic: license-file
16
+
17
+ # DeepMutSim
18
+
19
+ DeepMutSim generates simulations for all possible single nucleotide variants (SNVs) for the Matched Annotation from NCBI and EMBL-EBI (MANE) transcript, along with the corresponding protein using HGVS notation.
20
+
21
+ **INSTALLATION**
22
+
23
+ ```powershell
24
+ pip install deepmutsim
25
+ ```
26
+ CONFIGURATION (Mandatory)
27
+
28
+ Before you can use DeepMutSim, you must set two environment variables to query the NCBI Entrez database.
29
+
30
+ EMAIL: (Required by NCBI) A valid email address so NCBI can contact you if there's an issue with your queries.
31
+
32
+ API_KEY: (Recommended) An NCBI API key, which allows for a much higher query rate. You can obtain one from your NCBI account settings.
33
+
34
+ Linux/macOS:
35
+ ```Bash
36
+
37
+ export EMAIL="your.email@example.com"
38
+ export API_KEY="your_api_key_here"
39
+ ```
40
+ Windows (PowerShell):
41
+
42
+ ```powershell
43
+ set EMAIL="your.email@example.com"
44
+ set API_KEY="your_api_key_here"
45
+ ```
46
+ USAGE
47
+
48
+ Variant Simulator
49
+ ```Python
50
+
51
+ import deepmutsim
52
+ # Assumes EMAIL and API_KEY are set
53
+ deepmutsim.cds("INS")
54
+ ```
55
+
56
+ ```python
57
+ [('NM_000207.3:c.1A>G', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.1A>T', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.1A>C', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.2T>G', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.2T>A', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.2T>C', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.3G>A', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.3G>T', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.3G>C', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ... ('NM_000207.3:c.328A>T', 'NP_000198.1:p.(N110Y)', 'NP_000198.1:p.(Asn110Tyr)'), ('NM_000207.3:c.328A>C', 'NP_000198.1:p.(N110H)', 'NP_000198.1:p.(Asn110His)'), ('NM_000207.3:c.329A>T', 'NP_000198.1:p.(N110I)', 'NP_000198.1:p.(Asn110Ile)'), ('NM_000207.3:c.329A>C', 'NP_000198.1:p.(N110T)', 'NP_000198.1:p.(Asn110Thr)'), ('NM_000207.3:c.330C>T', 'NP_000198.1:p.(N110=)', 'NP_000198.1:p.(Asn110=)'), ('NM_000207.3:c.330C>A', 'NP_000198.1:p.(N110=)', 'NP_000198.1:p.(Asn110=)'), ('NM_000207.3:c.330C>G', 'NP_000198.1:p.(N110=)', 'NP_000198.1:p.(Asn110=)')]
58
+ ```
59
+ ```Python
60
+
61
+ deepmutsim.utr5("INS")
62
+ ```
63
+ ```python
64
+ ['NM_000207.3:c.-59A>G', 'NM_000207.3:c.-59A>T', 'NM_000207.3:c.-59A>C', 'NM_000207.3:c.-58G>A', 'NM_000207.3:c.-58G>T', ... 'NM_000207.3:c.-2C>A', 'NM_000207.3:c.-2C>T', 'NM_000207.3:c.-1C>G', 'NM_000207.3:c.-1C>A', 'NM_000207.3:c.-1C>T']
65
+ ```
66
+ ```Python
67
+
68
+ deepmutsim.utr3("INS")
69
+ ```
70
+ ```python
71
+ ['NM_000207.3:c.*1A>G', 'NM_000207.3:c.*1A>T', 'NM_000207.3:c.*1A>C', 'NM_000207.3:c.*2C>G', 'NM_000207.3:c.*2C>A', ... 'NM_000207.3:c.*72G>T', 'NM_000207.3:c.*72G>C', 'NM_000207.3:c.*73C>G', 'NM_000207.3:c.*73C>A', 'NM_000207.3:c.*73C>T']
72
+ ```
73
+ ```Python
74
+
75
+ deepmutsim.splice_site("INS")
76
+ ```
77
+ ```python
78
+ ['NC_000011.10(NM_000207.3):c.187+1G>A', 'NC_000011.10(NM_000207.3):c.187+1G>T', 'NC_000011.10(NM_000207.3):c.187+1G>C', 'NC_000011.10(NM_000207.3):c.187+2T>A', 'NC_000011.10(NM_000207.3):c.187+2T>G', 'NC_000011.10(NM_000207.3):c.187+2T>C', 'NC_000011.10(NM_000207.3):c.188-2A>G', 'NC_000011.10(NM_000207.3):c.188-2A>T', 'NC_000011.10(NM_000207.3):c.188-2A>C', 'NC_000011.10(NM_000207.3):c.188-1G>A', 'NC_000011.10(NM_000207.3):c.188-1G>T', 'NC_000011.10(NM_000207.3):c.188-1G>C']
79
+ ```
@@ -0,0 +1,63 @@
1
+ # DeepMutSim
2
+
3
+ DeepMutSim generates simulations for all possible single nucleotide variants (SNVs) for the Matched Annotation from NCBI and EMBL-EBI (MANE) transcript, along with the corresponding protein using HGVS notation.
4
+
5
+ **INSTALLATION**
6
+
7
+ ```powershell
8
+ pip install deepmutsim
9
+ ```
10
+ CONFIGURATION (Mandatory)
11
+
12
+ Before you can use DeepMutSim, you must set two environment variables to query the NCBI Entrez database.
13
+
14
+ EMAIL: (Required by NCBI) A valid email address so NCBI can contact you if there's an issue with your queries.
15
+
16
+ API_KEY: (Recommended) An NCBI API key, which allows for a much higher query rate. You can obtain one from your NCBI account settings.
17
+
18
+ Linux/macOS:
19
+ ```Bash
20
+
21
+ export EMAIL="your.email@example.com"
22
+ export API_KEY="your_api_key_here"
23
+ ```
24
+ Windows (PowerShell):
25
+
26
+ ```powershell
27
+ set EMAIL="your.email@example.com"
28
+ set API_KEY="your_api_key_here"
29
+ ```
30
+ USAGE
31
+
32
+ Variant Simulator
33
+ ```Python
34
+
35
+ import deepmutsim
36
+ # Assumes EMAIL and API_KEY are set
37
+ deepmutsim.cds("INS")
38
+ ```
39
+
40
+ ```python
41
+ [('NM_000207.3:c.1A>G', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.1A>T', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.1A>C', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.2T>G', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.2T>A', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.2T>C', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.3G>A', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.3G>T', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.3G>C', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ... ('NM_000207.3:c.328A>T', 'NP_000198.1:p.(N110Y)', 'NP_000198.1:p.(Asn110Tyr)'), ('NM_000207.3:c.328A>C', 'NP_000198.1:p.(N110H)', 'NP_000198.1:p.(Asn110His)'), ('NM_000207.3:c.329A>T', 'NP_000198.1:p.(N110I)', 'NP_000198.1:p.(Asn110Ile)'), ('NM_000207.3:c.329A>C', 'NP_000198.1:p.(N110T)', 'NP_000198.1:p.(Asn110Thr)'), ('NM_000207.3:c.330C>T', 'NP_000198.1:p.(N110=)', 'NP_000198.1:p.(Asn110=)'), ('NM_000207.3:c.330C>A', 'NP_000198.1:p.(N110=)', 'NP_000198.1:p.(Asn110=)'), ('NM_000207.3:c.330C>G', 'NP_000198.1:p.(N110=)', 'NP_000198.1:p.(Asn110=)')]
42
+ ```
43
+ ```Python
44
+
45
+ deepmutsim.utr5("INS")
46
+ ```
47
+ ```python
48
+ ['NM_000207.3:c.-59A>G', 'NM_000207.3:c.-59A>T', 'NM_000207.3:c.-59A>C', 'NM_000207.3:c.-58G>A', 'NM_000207.3:c.-58G>T', ... 'NM_000207.3:c.-2C>A', 'NM_000207.3:c.-2C>T', 'NM_000207.3:c.-1C>G', 'NM_000207.3:c.-1C>A', 'NM_000207.3:c.-1C>T']
49
+ ```
50
+ ```Python
51
+
52
+ deepmutsim.utr3("INS")
53
+ ```
54
+ ```python
55
+ ['NM_000207.3:c.*1A>G', 'NM_000207.3:c.*1A>T', 'NM_000207.3:c.*1A>C', 'NM_000207.3:c.*2C>G', 'NM_000207.3:c.*2C>A', ... 'NM_000207.3:c.*72G>T', 'NM_000207.3:c.*72G>C', 'NM_000207.3:c.*73C>G', 'NM_000207.3:c.*73C>A', 'NM_000207.3:c.*73C>T']
56
+ ```
57
+ ```Python
58
+
59
+ deepmutsim.splice_site("INS")
60
+ ```
61
+ ```python
62
+ ['NC_000011.10(NM_000207.3):c.187+1G>A', 'NC_000011.10(NM_000207.3):c.187+1G>T', 'NC_000011.10(NM_000207.3):c.187+1G>C', 'NC_000011.10(NM_000207.3):c.187+2T>A', 'NC_000011.10(NM_000207.3):c.187+2T>G', 'NC_000011.10(NM_000207.3):c.187+2T>C', 'NC_000011.10(NM_000207.3):c.188-2A>G', 'NC_000011.10(NM_000207.3):c.188-2A>T', 'NC_000011.10(NM_000207.3):c.188-2A>C', 'NC_000011.10(NM_000207.3):c.188-1G>A', 'NC_000011.10(NM_000207.3):c.188-1G>T', 'NC_000011.10(NM_000207.3):c.188-1G>C']
63
+ ```
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "DeepMutSim"
7
+ version = "1.0.0"
8
+ authors = [
9
+ { name="Liu Sun", email="sunliu@yxnu.edu.cn" },
10
+ { name="Jian Yang", email="yangjian@yxnu.edu.cn" },
11
+ ]
12
+ description = "Generates all possible SNVs for MANE transcripts using HGVS nomenclature."
13
+ readme = "README.md"
14
+ requires-python = ">=3.8"
15
+ dependencies = [
16
+ "biopython",
17
+ ]
18
+ classifiers = [
19
+ "Programming Language :: Python :: 3",
20
+ "Operating System :: OS Independent",
21
+ "License :: OSI Approved :: MIT License",
22
+ ]
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/liu-sun/DeepMutSim"
26
+ Issues = "https://github.com/liu-sun/DeepMutSim/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: DeepMutSim
3
+ Version: 1.0.0
4
+ Summary: Generates all possible SNVs for MANE transcripts using HGVS nomenclature.
5
+ Author-email: Liu Sun <sunliu@yxnu.edu.cn>, Jian Yang <yangjian@yxnu.edu.cn>
6
+ Project-URL: Homepage, https://github.com/liu-sun/DeepMutSim
7
+ Project-URL: Issues, https://github.com/liu-sun/DeepMutSim/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: biopython
15
+ Dynamic: license-file
16
+
17
+ # DeepMutSim
18
+
19
+ DeepMutSim generates simulations for all possible single nucleotide variants (SNVs) for the Matched Annotation from NCBI and EMBL-EBI (MANE) transcript, along with the corresponding protein using HGVS notation.
20
+
21
+ **INSTALLATION**
22
+
23
+ ```powershell
24
+ pip install deepmutsim
25
+ ```
26
+ CONFIGURATION (Mandatory)
27
+
28
+ Before you can use DeepMutSim, you must set two environment variables to query the NCBI Entrez database.
29
+
30
+ EMAIL: (Required by NCBI) A valid email address so NCBI can contact you if there's an issue with your queries.
31
+
32
+ API_KEY: (Recommended) An NCBI API key, which allows for a much higher query rate. You can obtain one from your NCBI account settings.
33
+
34
+ Linux/macOS:
35
+ ```Bash
36
+
37
+ export EMAIL="your.email@example.com"
38
+ export API_KEY="your_api_key_here"
39
+ ```
40
+ Windows (PowerShell):
41
+
42
+ ```powershell
43
+ set EMAIL="your.email@example.com"
44
+ set API_KEY="your_api_key_here"
45
+ ```
46
+ USAGE
47
+
48
+ Variant Simulator
49
+ ```Python
50
+
51
+ import deepmutsim
52
+ # Assumes EMAIL and API_KEY are set
53
+ deepmutsim.cds("INS")
54
+ ```
55
+
56
+ ```python
57
+ [('NM_000207.3:c.1A>G', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.1A>T', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.1A>C', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.2T>G', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.2T>A', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.2T>C', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.3G>A', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.3G>T', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ('NM_000207.3:c.3G>C', 'NP_000198.1:p.(M1?)', 'NP_000198.1:p.(Met1?)'), ... ('NM_000207.3:c.328A>T', 'NP_000198.1:p.(N110Y)', 'NP_000198.1:p.(Asn110Tyr)'), ('NM_000207.3:c.328A>C', 'NP_000198.1:p.(N110H)', 'NP_000198.1:p.(Asn110His)'), ('NM_000207.3:c.329A>T', 'NP_000198.1:p.(N110I)', 'NP_000198.1:p.(Asn110Ile)'), ('NM_000207.3:c.329A>C', 'NP_000198.1:p.(N110T)', 'NP_000198.1:p.(Asn110Thr)'), ('NM_000207.3:c.330C>T', 'NP_000198.1:p.(N110=)', 'NP_000198.1:p.(Asn110=)'), ('NM_000207.3:c.330C>A', 'NP_000198.1:p.(N110=)', 'NP_000198.1:p.(Asn110=)'), ('NM_000207.3:c.330C>G', 'NP_000198.1:p.(N110=)', 'NP_000198.1:p.(Asn110=)')]
58
+ ```
59
+ ```Python
60
+
61
+ deepmutsim.utr5("INS")
62
+ ```
63
+ ```python
64
+ ['NM_000207.3:c.-59A>G', 'NM_000207.3:c.-59A>T', 'NM_000207.3:c.-59A>C', 'NM_000207.3:c.-58G>A', 'NM_000207.3:c.-58G>T', ... 'NM_000207.3:c.-2C>A', 'NM_000207.3:c.-2C>T', 'NM_000207.3:c.-1C>G', 'NM_000207.3:c.-1C>A', 'NM_000207.3:c.-1C>T']
65
+ ```
66
+ ```Python
67
+
68
+ deepmutsim.utr3("INS")
69
+ ```
70
+ ```python
71
+ ['NM_000207.3:c.*1A>G', 'NM_000207.3:c.*1A>T', 'NM_000207.3:c.*1A>C', 'NM_000207.3:c.*2C>G', 'NM_000207.3:c.*2C>A', ... 'NM_000207.3:c.*72G>T', 'NM_000207.3:c.*72G>C', 'NM_000207.3:c.*73C>G', 'NM_000207.3:c.*73C>A', 'NM_000207.3:c.*73C>T']
72
+ ```
73
+ ```Python
74
+
75
+ deepmutsim.splice_site("INS")
76
+ ```
77
+ ```python
78
+ ['NC_000011.10(NM_000207.3):c.187+1G>A', 'NC_000011.10(NM_000207.3):c.187+1G>T', 'NC_000011.10(NM_000207.3):c.187+1G>C', 'NC_000011.10(NM_000207.3):c.187+2T>A', 'NC_000011.10(NM_000207.3):c.187+2T>G', 'NC_000011.10(NM_000207.3):c.187+2T>C', 'NC_000011.10(NM_000207.3):c.188-2A>G', 'NC_000011.10(NM_000207.3):c.188-2A>T', 'NC_000011.10(NM_000207.3):c.188-2A>C', 'NC_000011.10(NM_000207.3):c.188-1G>A', 'NC_000011.10(NM_000207.3):c.188-1G>T', 'NC_000011.10(NM_000207.3):c.188-1G>C']
79
+ ```
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/DeepMutSim.egg-info/PKG-INFO
5
+ src/DeepMutSim.egg-info/SOURCES.txt
6
+ src/DeepMutSim.egg-info/dependency_links.txt
7
+ src/DeepMutSim.egg-info/requires.txt
8
+ src/DeepMutSim.egg-info/top_level.txt
9
+ src/deepmutsim/__init__.py
@@ -0,0 +1 @@
1
+ biopython
@@ -0,0 +1 @@
1
+ deepmutsim
@@ -0,0 +1,611 @@
1
+ import os
2
+
3
+ from Bio import Entrez, SeqIO
4
+ from Bio.Data.CodonTable import standard_dna_table
5
+ from Bio.Data.IUPACData import unambiguous_dna_letters, protein_letters
6
+ from Bio.Seq import Seq
7
+ from Bio.SeqFeature import SimpleLocation
8
+ from Bio.SeqUtils import seq3, seq1
9
+
10
+ Entrez.email = os.environ["EMAIL"]
11
+ Entrez.api_key = os.environ["API_KEY"]
12
+ genetic_code = list(standard_dna_table.forward_table.keys())+standard_dna_table.stop_codons
13
+
14
+
15
+ def nm(gene: str) -> str:
16
+ stream = Entrez.esearch(
17
+ db="nucleotide",
18
+ term=f'{gene}[Gene Name] AND ("MANE Select"[Keyword] OR "MANE Plus Clinical"[keyword])',
19
+ )
20
+ record = Entrez.read(stream)
21
+ stream = Entrez.efetch(
22
+ db="nucleotide", id=record["IdList"], rettype="gb", retmode="text"
23
+ )
24
+ seqrecord = SeqIO.read(stream, "genbank")
25
+ return seqrecord
26
+
27
+
28
+ def np(gene: str) -> str:
29
+ stream = Entrez.esearch(
30
+ db="protein",
31
+ term=f'{gene}[Gene Name] AND ("MANE Select"[Keyword] OR "MANE Plus Clinical"[keyword])',
32
+ )
33
+ record = Entrez.read(stream)
34
+ stream = Entrez.efetch(
35
+ db="protein", id=record["IdList"], rettype="fasta", retmode="text"
36
+ )
37
+ seqrecord = SeqIO.read(stream, "fasta")
38
+ return seqrecord
39
+
40
+
41
+ def nc(gene: str) -> str:
42
+ stream = Entrez.esearch(
43
+ db="nucleotide",
44
+ term=f'{gene}[Gene Name] AND "Primary Assembly"[Title] AND human[Organism]',
45
+ )
46
+ record = Entrez.read(stream)
47
+ stream = Entrez.efetch(
48
+ db="nucleotide", id=record["IdList"], rettype="acc", retmode="text"
49
+ )
50
+ acc = stream.read().strip()
51
+ return acc
52
+
53
+
54
+ def cds(gene: str) -> list:
55
+ variants = []
56
+ seqrecord = nm(gene)
57
+ protein_seqrecord = np(gene)
58
+ protein = str(protein_seqrecord.seq)
59
+ protein_id = protein_seqrecord.id
60
+ for feature in seqrecord.features:
61
+ if feature.type == "CDS":
62
+ cds = feature.extract(seqrecord).seq
63
+ for index, codon in enumerate(range(0, len(cds) - 3, 3)):
64
+ for base in unambiguous_dna_letters:
65
+ if index == 0:
66
+ if base != "A":
67
+ variants.append(
68
+ (
69
+ f"{seqrecord.id}:c.1A>{base}",
70
+ f"{protein_id}:p.(M1?)",
71
+ f"{protein_id}:p.(Met1?)",
72
+ )
73
+ )
74
+ else:
75
+ if base != cds[codon]:
76
+ seq = Seq(base) + cds[codon + 1 : codon + 3]
77
+ if protein[index] != seq.translate():
78
+ variants.append(
79
+ (
80
+ f"{seqrecord.id}:c.{codon + 1}{cds[codon]}>{base}",
81
+ f"{protein_id}:p.({protein[index]}{index + 1}{seq.translate()})",
82
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}{seq3(seq.translate())})",
83
+ )
84
+ )
85
+ else:
86
+ variants.append(
87
+ (
88
+ f"{seqrecord.id}:c.{codon + 1}{cds[codon]}>{base}",
89
+ f"{protein_id}:p.({protein[index]}{index + 1}=)",
90
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}=)",
91
+ )
92
+ )
93
+ if index == 0:
94
+ if base != "T":
95
+ variants.append(
96
+ (
97
+ f"{seqrecord.id}:c.2T>{base}",
98
+ f"{protein_id}:p.(M1?)",
99
+ f"{protein_id}:p.(Met1?)",
100
+ )
101
+ )
102
+ else:
103
+ if base != cds[codon + 1]:
104
+ seq = cds[codon] + Seq(base) + cds[codon + 2]
105
+ if protein[index] != seq.translate():
106
+ variants.append(
107
+ (
108
+ f"{seqrecord.id}:c.{codon + 2}{cds[codon + 1]}>{base}",
109
+ f"{protein_id}:p.({protein[index]}{index + 1}{seq.translate()})",
110
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}{seq3(seq.translate())})",
111
+ )
112
+ )
113
+ else:
114
+ variants.append(
115
+ (
116
+ f"{seqrecord.id}:c.{codon + 2}{cds[codon + 1]}>{base}",
117
+ f"{protein_id}:p.({protein[index]}{index + 1}=)",
118
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}=)",
119
+ )
120
+ )
121
+ if index == 0:
122
+ if base != "G":
123
+ variants.append(
124
+ (
125
+ f"{seqrecord.id}:c.3G>{base}",
126
+ f"{protein_id}:p.(M1?)",
127
+ f"{protein_id}:p.(Met1?)",
128
+ )
129
+ )
130
+ else:
131
+ if base != cds[codon + 2]:
132
+ seq = cds[codon : codon + 2] + Seq(base)
133
+ if protein[index] != seq.translate():
134
+ variants.append(
135
+ (
136
+ f"{seqrecord.id}:c.{codon + 3}{cds[codon + 2]}>{base}",
137
+ f"{protein_id}:p.({protein[index]}{index + 1}{seq.translate()})",
138
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}{seq3(seq.translate())})",
139
+ )
140
+ )
141
+ else:
142
+ variants.append(
143
+ (
144
+ f"{seqrecord.id}:c.{codon + 3}{cds[codon + 2]}>{base}",
145
+ f"{protein_id}:p.({protein[index]}{index + 1}=)",
146
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}=)",
147
+ )
148
+ )
149
+ return variants
150
+
151
+
152
+ def utr5(gene: str) -> list:
153
+ variants = []
154
+ seqrecord = nm(gene)
155
+ for feature in seqrecord.features:
156
+ if feature.type == "CDS":
157
+ utr5 = SimpleLocation(0, feature.location.start).extract(seqrecord).seq
158
+ for index in range(len(utr5)):
159
+ for base in unambiguous_dna_letters:
160
+ if base != utr5[index]:
161
+ variants.append(
162
+ f"{seqrecord.id}:c.{index - len(utr5)}{utr5[index]}>{base}"
163
+ )
164
+ return variants
165
+
166
+
167
+ def utr3(gene: str) -> list:
168
+ variants = []
169
+ seqrecord = nm(gene)
170
+ for feature in seqrecord.features:
171
+ if feature.type == "CDS":
172
+ utr3 = (
173
+ SimpleLocation(feature.location.end, len(seqrecord))
174
+ .extract(seqrecord)
175
+ .seq
176
+ )
177
+ for index in range(len(utr3)):
178
+ for base in unambiguous_dna_letters:
179
+ if base != utr3[index]:
180
+ variants.append(f"{seqrecord.id}:c.*{index + 1}{utr3[index]}>{base}")
181
+ return variants
182
+
183
+
184
+ def splice_site(gene: str) -> list:
185
+ variants = []
186
+ seqrecord = nm(gene)
187
+ acc = nc(gene)
188
+ splicing = []
189
+ for feature in seqrecord.features:
190
+ if feature.type == "CDS":
191
+ start = feature.location.start
192
+ end = feature.location.end
193
+ for feature in seqrecord.features:
194
+ if feature.type == "exon":
195
+ if feature.location.end < start or feature.location.start > end:
196
+ continue
197
+ else:
198
+ splicing.extend(
199
+ (feature.location.start - start, feature.location.end - start)
200
+ )
201
+
202
+ for coordinate in range(1, len(splicing) - 1, 2):
203
+ site = splicing[coordinate], splicing[coordinate] + 1
204
+ for base in unambiguous_dna_letters:
205
+ if base != "G":
206
+ variants.append(f"{acc}({seqrecord.id}):c.{site[0]}+1G>{base}")
207
+ if base != "T":
208
+ variants.append(f"{acc}({seqrecord.id}):c.{site[0]}+2T>{base}")
209
+ if base != "A":
210
+ variants.append(f"{acc}({seqrecord.id}):c.{site[1]}-2A>{base}")
211
+ if base != "G":
212
+ variants.append(f"{acc}({seqrecord.id}):c.{site[1]}-1G>{base}")
213
+ return variants
214
+
215
+
216
+ def aa_sub(gene: str) -> list:
217
+ variants = []
218
+ seqrecord = np(gene)
219
+ for index, residue in enumerate(seqrecord.seq, 1):
220
+ for aa in protein_letters:
221
+ if aa != residue:
222
+ if index != 1:
223
+ variants.append(
224
+ (
225
+ f"{seqrecord.id}:p.({residue}{index}{aa})",
226
+ f"{seqrecord.id}:p.({seq3(residue)}{index}{seq3(aa)})",
227
+ )
228
+ )
229
+ else:
230
+ variants.append(
231
+ (
232
+ f"{seqrecord.id}:p.({residue}{index}?)",
233
+ f"{seqrecord.id}:p.({seq3(residue)}{index}?)",
234
+ )
235
+ )
236
+ return variants
237
+
238
+
239
+ def codon_sub(gene: str) -> list:
240
+ variants = []
241
+ seqrecord = nm(gene)
242
+ for feature in seqrecord.features:
243
+ if feature.type == "CDS":
244
+ cds = feature.location.extract(seqrecord).seq
245
+ for index, codon in enumerate(range(0, len(cds) - 3, 3)):
246
+ for base in genetic_code:
247
+ if base != cds[codon : codon + 3]:
248
+ seq = Seq(base)
249
+ if all(
250
+ (
251
+ base[0] != cds[codon],
252
+ base[1] != cds[codon + 1],
253
+ base[2] != cds[codon + 2],
254
+ )
255
+ ):
256
+ variants.append(
257
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 3}delins{base}"
258
+ )
259
+ elif all(
260
+ (
261
+ base[0] == cds[codon],
262
+ base[1] != cds[codon + 1],
263
+ base[2] != cds[codon + 2],
264
+ )
265
+ ):
266
+ variants.append(
267
+ f"{seqrecord.id}:c.{codon + 2}_{codon + 3}delins{base[1:3]}"
268
+ )
269
+ elif all(
270
+ (
271
+ base[0] != cds[codon],
272
+ base[1] == cds[codon + 1],
273
+ base[2] != cds[codon + 2],
274
+ )
275
+ ):
276
+ variants.append(
277
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 3}delins{base}"
278
+ )
279
+ elif all(
280
+ (
281
+ base[0] != cds[codon],
282
+ base[1] != cds[codon + 1],
283
+ base[2] == cds[codon + 2],
284
+ )
285
+ ):
286
+ variants.append(
287
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 2}delins{base[0:2]}"
288
+ )
289
+ elif all(
290
+ (
291
+ base[0] == cds[codon],
292
+ base[1] == cds[codon + 1],
293
+ base[2] != cds[codon + 2],
294
+ )
295
+ ):
296
+ variants.append(
297
+ f"{seqrecord.id}:c.{codon + 3}{cds[codon + 2]}>{base[2]}"
298
+ )
299
+ elif all(
300
+ (
301
+ base[0] == cds[codon],
302
+ base[1] != cds[codon + 1],
303
+ base[2] == cds[codon + 2],
304
+ )
305
+ ):
306
+ variants.append(
307
+ f"{seqrecord.id}:c.{codon + 2}{cds[codon + 1]}>{base[1]}"
308
+ )
309
+ elif all(
310
+ (
311
+ base[0] != cds[codon],
312
+ base[1] == cds[codon + 1],
313
+ base[2] == cds[codon + 2],
314
+ )
315
+ ):
316
+ variants.append(
317
+ f"{seqrecord.id}:c.{codon + 1}{cds[codon]}>{base[0]}"
318
+ )
319
+ return variants
320
+
321
+
322
+ def missense(gene: str) -> list:
323
+ variants = []
324
+ seqrecord = nm(gene)
325
+ protein_seqrecord = np(gene)
326
+ protein = str(protein_seqrecord.seq)
327
+ protein_id = protein_seqrecord.id
328
+ for feature in seqrecord.features:
329
+ if feature.type == "CDS":
330
+ cds = feature.location.extract(seqrecord).seq
331
+ for index, codon in enumerate(range(0, len(cds) - 3, 3)):
332
+ for base in genetic_code:
333
+ if base != cds[codon : codon + 3]:
334
+ seq = Seq(base)
335
+ if index == 0:
336
+ if all(
337
+ (
338
+ base[0] != cds[codon],
339
+ base[1] != cds[codon + 1],
340
+ base[2] != cds[codon + 2],
341
+ )
342
+ ):
343
+ variants.append(
344
+ (
345
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 3}delins{base}",
346
+ f"{protein_id}:p.(M1?)",
347
+ f"{protein_id}:p.(Met1?)",
348
+ )
349
+ )
350
+ elif all(
351
+ (
352
+ base[0] == cds[codon],
353
+ base[1] != cds[codon + 1],
354
+ base[2] != cds[codon + 2],
355
+ )
356
+ ):
357
+ variants.append(
358
+ (
359
+ f"{seqrecord.id}:c.{codon + 2}_{codon + 3}delins{base[1:3]}",
360
+ f"{protein_id}:p.(M1?)",
361
+ f"{protein_id}:p.(Met1?)",
362
+ )
363
+ )
364
+ elif all(
365
+ (
366
+ base[0] != cds[codon],
367
+ base[1] == cds[codon + 1],
368
+ base[2] != cds[codon + 2],
369
+ )
370
+ ):
371
+ variants.append(
372
+ (
373
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 3}delins{base}",
374
+ f"{protein_id}:p.(M1?)",
375
+ f"{protein_id}:p.(Met1?)",
376
+ )
377
+ )
378
+ elif all(
379
+ (
380
+ base[0] != cds[codon],
381
+ base[1] != cds[codon + 1],
382
+ base[2] == cds[codon + 2],
383
+ )
384
+ ):
385
+ variants.append(
386
+ (
387
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 2}delins{base[0:2]}",
388
+ f"{protein_id}:p.(M1?)",
389
+ f"{protein_id}:p.(Met1?)",
390
+ )
391
+ )
392
+ elif all(
393
+ (
394
+ base[0] == cds[codon],
395
+ base[1] == cds[codon + 1],
396
+ base[2] != cds[codon + 2],
397
+ )
398
+ ):
399
+ variants.append(
400
+ (
401
+ f"{seqrecord.id}:c.{codon + 3}{cds[codon + 2]}>{base[2]}",
402
+ f"{protein_id}:p.(M1?)",
403
+ f"{protein_id}:p.(Met1?)",
404
+ )
405
+ )
406
+ elif all(
407
+ (
408
+ base[0] == cds[codon],
409
+ base[1] != cds[codon + 1],
410
+ base[2] == cds[codon + 2],
411
+ )
412
+ ):
413
+ variants.append(
414
+ (
415
+ f"{seqrecord.id}:c.{codon + 2}{cds[codon + 1]}>{base[1]}",
416
+ f"{protein_id}:p.(M1?)",
417
+ f"{protein_id}:p.(Met1?)",
418
+ )
419
+ )
420
+ elif all(
421
+ (
422
+ base[0] != cds[codon],
423
+ base[1] == cds[codon + 1],
424
+ base[2] == cds[codon + 2],
425
+ )
426
+ ):
427
+ variants.append(
428
+ (
429
+ f"{seqrecord.id}:c.{codon + 1}{cds[codon]}>{base[0]}",
430
+ f"{protein_id}:p.(M1?)",
431
+ f"{protein_id}:p.(Met1?)",
432
+ )
433
+ )
434
+ else:
435
+ if all(
436
+ (
437
+ base[0] != cds[codon],
438
+ base[1] != cds[codon + 1],
439
+ base[2] != cds[codon + 2],
440
+ )
441
+ ):
442
+ if protein[index] != seq.translate():
443
+ variants.append(
444
+ (
445
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 3}delins{base}",
446
+ f"{protein_id}:p.({protein[index]}{index + 1}{seq.translate()})",
447
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}{seq3(seq.translate())})",
448
+ )
449
+ )
450
+ else:
451
+ variants.append(
452
+ (
453
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 3}delins{base}",
454
+ f"{protein_id}:p.({protein[index]}{index + 1}=)",
455
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}=)",
456
+ )
457
+ )
458
+ elif all(
459
+ (
460
+ base[0] == cds[codon],
461
+ base[1] != cds[codon + 1],
462
+ base[2] != cds[codon + 2],
463
+ )
464
+ ):
465
+ if protein[index] != seq.translate():
466
+ variants.append(
467
+ (
468
+ f"{seqrecord.id}:c.{codon + 2}_{codon + 3}delins{base[1:3]}",
469
+ f"{protein_id}:p.({protein[index]}{index + 1}{seq.translate()})",
470
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}{seq3(seq.translate())})",
471
+ )
472
+ )
473
+ else:
474
+ variants.append(
475
+ (
476
+ f"{seqrecord.id}:c.{codon + 2}_{codon + 3}delins{base[1:3]}",
477
+ f"{protein_id}:p.({protein[index]}{index + 1}=)",
478
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}=)",
479
+ )
480
+ )
481
+ elif all(
482
+ (
483
+ base[0] != cds[codon],
484
+ base[1] == cds[codon + 1],
485
+ base[2] != cds[codon + 2],
486
+ )
487
+ ):
488
+ if protein[index] != seq.translate():
489
+ variants.append(
490
+ (
491
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 3}delins{base}",
492
+ f"{protein_id}:p.({protein[index]}{index + 1}{seq.translate()})",
493
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}{seq3(seq.translate())})",
494
+ )
495
+ )
496
+ else:
497
+ variants.append(
498
+ (
499
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 3}delins{base}",
500
+ f"{protein_id}:p.({protein[index]}{index + 1}=)",
501
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}=)",
502
+ )
503
+ )
504
+ elif all(
505
+ (
506
+ base[0] != cds[codon],
507
+ base[1] != cds[codon + 1],
508
+ base[2] == cds[codon + 2],
509
+ )
510
+ ):
511
+ if protein[index] != seq.translate():
512
+ variants.append(
513
+ (
514
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 2}delins{base[0:2]}",
515
+ f"{protein_id}:p.({protein[index]}{index + 1}{seq.translate()})",
516
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}{seq3(seq.translate())})",
517
+ )
518
+ )
519
+ else:
520
+ variants.append(
521
+ (
522
+ f"{seqrecord.id}:c.{codon + 1}_{codon + 2}delins{base[0:2]}",
523
+ f"{protein_id}:p.({protein[index]}{index + 1}=)",
524
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}=)",
525
+ )
526
+ )
527
+ elif all(
528
+ (
529
+ base[0] == cds[codon],
530
+ base[1] == cds[codon + 1],
531
+ base[2] != cds[codon + 2],
532
+ )
533
+ ):
534
+ if protein[index] != seq.translate():
535
+ variants.append(
536
+ (
537
+ f"{seqrecord.id}:c.{codon + 3}{cds[codon + 2]}>{base[2]}",
538
+ f"{protein_id}:p.({protein[index]}{index + 1}{seq.translate()})",
539
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}{seq3(seq.translate())})",
540
+ )
541
+ )
542
+ else:
543
+ variants.append(
544
+ (
545
+ f"{seqrecord.id}:c.{codon + 3}{cds[codon + 2]}>{base[2]}",
546
+ f"{protein_id}:p.({protein[index]}{index + 1}=)",
547
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}=)",
548
+ )
549
+ )
550
+ elif all(
551
+ (
552
+ base[0] == cds[codon],
553
+ base[1] != cds[codon + 1],
554
+ base[2] == cds[codon + 2],
555
+ )
556
+ ):
557
+ if protein[index] != seq.translate():
558
+ variants.append(
559
+ (
560
+ f"{seqrecord.id}:c.{codon + 2}{cds[codon + 1]}>{base[1]}",
561
+ f"{protein_id}:p.({protein[index]}{index + 1}{seq.translate()})",
562
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}{seq3(seq.translate())})",
563
+ )
564
+ )
565
+ else:
566
+ variants.append(
567
+ (
568
+ f"{seqrecord.id}:c.{codon + 2}{cds[codon + 1]}>{base[1]}",
569
+ f"{protein_id}:p.({protein[index]}{index + 1}=)",
570
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}=)",
571
+ )
572
+ )
573
+ elif all(
574
+ (
575
+ base[0] != cds[codon],
576
+ base[1] == cds[codon + 1],
577
+ base[2] == cds[codon + 2],
578
+ )
579
+ ):
580
+ if protein[index] != seq.translate():
581
+ variants.append(
582
+ (
583
+ f"{seqrecord.id}:c.{codon + 1}{cds[codon]}>{base[0]}",
584
+ f"{protein_id}:p.({protein[index]}{index + 1}{seq.translate()})",
585
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}{seq3(seq.translate())})",
586
+ )
587
+ )
588
+ else:
589
+ variants.append(
590
+ (
591
+ f"{seqrecord.id}:c.{codon + 1}{cds[codon]}>{base[0]}",
592
+ f"{protein_id}:p.({protein[index]}{index + 1}=)",
593
+ f"{protein_id}:p.({seq3(protein[index])}{index + 1}=)",
594
+ )
595
+ )
596
+ return variants
597
+
598
+
599
+ if __name__ == "__main__":
600
+ import pprint
601
+
602
+ # pprint.pprint(cds("INS"))
603
+ # pprint.pprint(missense("INS"))
604
+ # pprint.pprint(aa_sub("INS"))
605
+ # pprint.pprint(utr5("INS"))
606
+ # pprint.pprint(utr3("INS"))
607
+ pprint.pprint(splice_site("INS"))
608
+ # pprint.pprint(codon_sub("INS"))
609
+ # pprint.pprint(nc("INS"))
610
+ # pprint.pprint(np("INS"))
611
+ # pprint.pprint(nm("INS"))