introvoyz041 commited on
Commit
852751b
1 Parent(s): ec09c07

Migrated from GitHub

Browse files
data/LICENSE ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ Copyright 2024 Arc Institute
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/bridgernadesigner/__init__.py ADDED
File without changes
data/bridgernadesigner/classes.py ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from Bio.Seq import reverse_complement
2
+ from bridgernadesigner import errors
3
+ import re
4
+
5
+ class WTBridgeRNA177nt:
6
+
7
+ TEMPLATE = "AGTGCAGAGAAAATCGGCCAGTTTTCTCTGCCTGCAGTCCGCATGCCGTNNNNNNNNNTGGGTTCTAACCTGTNNNNNNNNNTTATGCAGCGGACTGCCTTTCTCCCAAAGTGATAAACCGGNNNNNNNNATGGACCGGTTTTCCCGGTAATCCGTNNTTNNNNNNNTGGTTTCACT"
8
+ DOT_STRUC_P1 = "...(((((((((((......))))))))))).((((((((((.(((............(((((....)))))..............))))).)))))))).........((((....(((.............((((((.....)))))...)...............)))..))))"
9
+ DOT_STRUC_P2 = "((.(((((((((((......)))))))))))))(((((((((.(((.............<(((.<>.)))>...............))))))))))))...........((((...<(((..........<.(((((((.....)))))...))....>.........)))>.))))"
10
+ GUIDES = ".................................................LLLLLLLCC...............RRRRRCCHH........................................lllllllc..........................rr..rrrcchh.........."
11
+
12
+ LTG_REGION = (49, 58)
13
+ RTG_REGION = (73, 80)
14
+ LDG_REGION = (122, 130)
15
+ RDG1_REGION = (160, 165)
16
+ RDG2_REGION = (156, 158)
17
+ TBL_HSG_REGION = (80, 82)
18
+ DBL_HSG_REGION = (165, 167)
19
+
20
+ def __init__(self):
21
+ self.bridge_sequence = str(self.TEMPLATE)
22
+ self.target = None
23
+ self.donor = None
24
+
25
+ def update_target(self, target):
26
+
27
+ self.target = target
28
+
29
+ core = target[7:9]
30
+ if core not in ["CT", "GT"]:
31
+ errors.NotCTorGTCoreWarning()
32
+ if core not in ["CT", "GT", "AT", "TT"]:
33
+ errors.NotNTCoreWarning()
34
+
35
+ bridgeseq = list(self.bridge_sequence)
36
+
37
+ bridgeseq[self.LTG_REGION[0]:self.LTG_REGION[1]] = list(target[:9])
38
+ bridgeseq[self.RTG_REGION[0]:self.RTG_REGION[1]] = list(reverse_complement(target[7:]))
39
+
40
+ self.bridge_sequence = "".join(bridgeseq)
41
+
42
+ def update_donor(self, donor):
43
+ self.donor = donor
44
+
45
+ if self.has_donor_p7C():
46
+ errors.DonorP7CWarning()
47
+
48
+ bridgeseq = list(self.bridge_sequence)
49
+ bridgeseq[self.LDG_REGION[0]:self.LDG_REGION[1]] = list(donor[:8])
50
+ bridgeseq[self.RDG1_REGION[0]:self.RDG1_REGION[1]] = list(reverse_complement(donor[7:-2]))
51
+ bridgeseq[self.RDG2_REGION[0]:self.RDG2_REGION[1]] = list(reverse_complement(donor[-2:]))
52
+
53
+ self.bridge_sequence = "".join(bridgeseq)
54
+
55
+ def update_hsg(self):
56
+ bridgeseq = list(self.bridge_sequence)
57
+
58
+ target_p6p7, donor_p6p7 = self.get_p6p7()
59
+
60
+ if target_p6p7 != donor_p6p7:
61
+ bridgeseq[self.TBL_HSG_REGION[0]:self.TBL_HSG_REGION[1]] = list(reverse_complement(donor_p6p7))
62
+ bridgeseq[self.DBL_HSG_REGION[0]:self.DBL_HSG_REGION[1]] = list(reverse_complement(target_p6p7))
63
+ else:
64
+ errors.MatchingP6P7Warning()
65
+ bridgeseq[self.TBL_HSG_REGION[0]:self.TBL_HSG_REGION[1]] = list(reverse_complement(donor_p6p7))
66
+ bridgeseq[self.DBL_HSG_REGION[0]:self.DBL_HSG_REGION[1]] = list(target_p6p7)
67
+
68
+ self.bridge_sequence = "".join(bridgeseq)
69
+
70
+ @staticmethod
71
+ def check_target_length(target):
72
+ if len(target) != 14:
73
+ raise errors.TargetLengthError()
74
+
75
+ @staticmethod
76
+ def check_donor_length(donor):
77
+ if len(donor) != 14:
78
+ raise errors.DonorLengthError()
79
+
80
+ @staticmethod
81
+ def check_core_match(target, donor):
82
+ if target[7:9] != donor[7:9]:
83
+ raise errors.CoreMismatchError()
84
+
85
+ @staticmethod
86
+ def check_donor_is_dna(donor):
87
+ if re.match("^[ATCG]*$", donor) is None:
88
+ raise errors.DonorNotDNAError()
89
+
90
+ # @staticmethod
91
+ def check_target_is_dna(target):
92
+ if re.match("^[ATCG]*$", target) is None:
93
+ raise errors.TargetNotDNAError()
94
+
95
+ def get_p6p7(self):
96
+ return self.target[5:7], self.donor[5:7]
97
+
98
+ def has_donor_p7C(self):
99
+ if self.donor[6] == "C":
100
+ return True
101
+ else:
102
+ return False
103
+
104
+ def has_matching_p6p7(self):
105
+ if self.target[5:7] == self.donor[5:7]:
106
+ return True
107
+ else:
108
+ return False
109
+
110
+ def annealing_oligos(self, lh_overhang="TAGC", rh_overhang="GGCC"):
111
+ fiveprime_stem_loop_top = lh_overhang+self.bridge_sequence[:45]
112
+ fiveprime_stem_loop_btm = reverse_complement(self.bridge_sequence[:49])
113
+ tbl_top = self.bridge_sequence[45:105]
114
+ tbl_btm = reverse_complement(self.bridge_sequence[49:109])
115
+ dbl_top = self.bridge_sequence[105:177]
116
+ dbl_btm = rh_overhang+reverse_complement(self.bridge_sequence[109:177])
117
+
118
+ return {
119
+ 'fiveprime_stem_loop_top': fiveprime_stem_loop_top,
120
+ 'fiveprime_stem_loop_btm': fiveprime_stem_loop_btm,
121
+ 'tbl_top': tbl_top, 'tbl_btm': tbl_btm,
122
+ 'dbl_top': dbl_top, 'dbl_btm': dbl_btm
123
+ }
124
+
125
+ def format_fasta(self, include_annealing_oligos=False,
126
+ lh_overhang="TAGC", rh_overhang="GGCC"):
127
+ out = ">BridgeRNA_tgt_{}_dnr_{}\n".format(self.target, self.donor)
128
+ out += self.bridge_sequence
129
+ if include_annealing_oligos:
130
+ oligos = self.annealing_oligos(lh_overhang, rh_overhang)
131
+ out += '\n>BridgeRNA_tgt_{}_dnr_{}_oligo_anneal_fiveprime_stem_loop_top\n{}\n'.format(
132
+ self.target, self.donor, oligos['fiveprime_stem_loop_top']
133
+ )
134
+ out += '>BridgeRNA_tgt_{}_dnr_{}_oligo_anneal_fiveprime_stem_loop_btm\n{}\n'.format(
135
+ self.target, self.donor, oligos['fiveprime_stem_loop_btm']
136
+ )
137
+ out += '>BridgeRNA_tgt_{}_dnr_{}_oligo_anneal_tbl_top\n{}\n'.format(
138
+ self.target, self.donor, oligos['tbl_top']
139
+ )
140
+ out += '>BridgeRNA_tgt_{}_dnr_{}_oligo_anneal_tbl_btm\n{}\n'.format(
141
+ self.target, self.donor, oligos['tbl_btm']
142
+ )
143
+ out += '>BridgeRNA_tgt_{}_dnr_{}_oligo_anneal_dbl_top\n{}\n'.format(
144
+ self.target, self.donor, oligos['dbl_top']
145
+ )
146
+ out += '>BridgeRNA_tgt_{}_dnr_{}_oligo_anneal_dbl_btm\n{}'.format(
147
+ self.target, self.donor, oligos['dbl_btm']
148
+ )
149
+
150
+ return out
151
+
152
+ def format_stockholm(self, whitespaces=5):
153
+ seqname = "BridgeRNA_tgt_{}_dnr_{}".format(self.target, self.donor)
154
+ leader_cols = len(seqname)+whitespaces
155
+ out = "# STOCKHOLM 1.0\n"
156
+ out += seqname+" "*(leader_cols-len(seqname))+self.bridge_sequence+"\n"
157
+ template_feat = "#=GC bRNA_template"
158
+ out += template_feat + " "*((leader_cols-len(template_feat))) + self.TEMPLATE + "\n"
159
+ guide_feat = "#=GC guides"
160
+ out += guide_feat + " "*((leader_cols-len(guide_feat))) + self.GUIDES + "\n"
161
+ ss_feat = "#=GC SS"
162
+ out += ss_feat + " " * ((leader_cols - len(ss_feat))) + self.DOT_STRUC_P2 + "\n"
163
+
164
+ donor_p7 = self.donor[6]
165
+ target_p6p7 = self.target[5:7]
166
+ donor_p6p7 = self.donor[5:7]
167
+ core = self.target[7:9]
168
+
169
+ warning_feat = "#=GF WARNING"
170
+ if donor_p7 == 'C':
171
+ out += warning_feat + " Donor P7 is C, this was found to be very inefficient in a screen.\n"
172
+ if target_p6p7 == donor_p6p7:
173
+ out += warning_feat + " Target P6-P7 and Donor P6-P7 match, efficiency is unclear.\n"
174
+ if core != 'CT' and core != 'GT':
175
+ out += warning_feat + " Core is not CT or GT, efficiency is unclear.\n"
176
+ if core != 'CT' and core != 'GT' and core != 'AT' and core != 'TT':
177
+ out += warning_feat + " Core does not follow the expected NT format, likely inefficient.\n"
178
+ out += "//"
179
+ return out
180
+
181
+ # Custom print function
182
+ def __str__(self):
183
+ out = "<WTBridgeRNA177nt>\n"
184
+ out += '- Programmed target: {}\n'.format(self.target)
185
+ out += '- Programmed donor: {}\n'.format(self.donor)
186
+ out += '- Bridge RNA sequence: {}'.format(self.bridge_sequence)
187
+ return out
data/bridgernadesigner/errors.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import warnings
2
+
3
+ class TargetNotDNAError(Exception):
4
+ def __init__(self, message="The target sequence must be DNA."):
5
+ self.message = message
6
+ super().__init__(self.message)
7
+
8
+ class DonorNotDNAError(Exception):
9
+ def __init__(self, message="The donor sequence must be DNA."):
10
+ self.message = message
11
+ super().__init__(self.message)
12
+
13
+ class TargetLengthError(Exception):
14
+ def __init__(self, message="The target sequence must be exactly 14 nucleotides long."):
15
+ self.message = message
16
+ super().__init__(self.message)
17
+
18
+ class DonorLengthError(Exception):
19
+ def __init__(self, message="The donor sequence must be exactly 14 nucleotides long."):
20
+ self.message = message
21
+ super().__init__(self.message)
22
+
23
+ class CoreMismatchError(Exception):
24
+ def __init__(self, message="That target and donor cores must be the same."):
25
+ self.message = message
26
+ super().__init__(self.message)
27
+
28
+ def DonorP7CWarning():
29
+ warnings.warn("Donor P7 is C, this was found to be very inefficient in a screen.")
30
+
31
+ def MatchingP6P7Warning():
32
+ warnings.warn("Target P6-P7 and Donor P6-P7 match, efficiency is unclear. DBL HSG forced to be anti-complementary.")
33
+
34
+ def NotCTorGTCoreWarning():
35
+ warnings.warn("Core is not CT or GT, efficiency is unclear.")
36
+
37
+ def NotNTCoreWarning():
38
+ warnings.warn("Core does not follow the expected NT format, likely inefficient.")
data/bridgernadesigner/main.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import click
2
+ import sys
3
+ from bridgernadesigner import errors, run
4
+ from bridgernadesigner.classes import WTBridgeRNA177nt
5
+
6
+ @click.group(invoke_without_command=True)
7
+ @click.option('--target', '-t', required=True, help="14nt target sequence")
8
+ @click.option('--donor', '-d', required=True, help="14nt donor sequence")
9
+ @click.option('--output-format', '-of', default='stockholm', type=click.Choice(['stockholm', 'fasta']))
10
+ @click.option('--include-annealing-oligos/--no-include-annealing-oligos', default=True,
11
+ help="Include annealing oligos in the output. Only available for FASTA output format. default=True")
12
+ @click.option('--annealing-oligos-lh-overhang', default="TAGC", help="5' overhang for annealing oligos. default=TAGC")
13
+ @click.option('--annealing-oligos-rh-overhang', default="GGCC", help="3' overhang for annealing oligos. default=GGCC")
14
+ @click.pass_context
15
+ def cli(ctx, target, donor, output_format, include_annealing_oligos,
16
+ annealing_oligos_lh_overhang, annealing_oligos_rh_overhang):
17
+ if ctx.invoked_subcommand is None:
18
+ ctx.invoke(default_command, target=target, donor=donor, output_format=output_format,
19
+ include_annealing_oligos=include_annealing_oligos,
20
+ annealing_oligos_lh_overhang=annealing_oligos_lh_overhang,
21
+ annealing_oligos_rh_overhang=annealing_oligos_rh_overhang)
22
+
23
+ @cli.command()
24
+ @click.pass_context
25
+ def default_command(ctx, target, donor, output_format,
26
+ include_annealing_oligos, annealing_oligos_lh_overhang, annealing_oligos_rh_overhang):
27
+
28
+ target = target.upper()
29
+ donor = donor.upper()
30
+
31
+ try:
32
+ WTBridgeRNA177nt.check_target_length(target)
33
+ except errors.TargetLengthError as e:
34
+ print("ERROR:", e)
35
+ print("Exiting...")
36
+ sys.exit()
37
+
38
+ try:
39
+ WTBridgeRNA177nt.check_donor_length(donor)
40
+ except errors.DonorLengthError as e:
41
+ print("ERROR:", e)
42
+ print("Exiting...")
43
+ sys.exit()
44
+
45
+ try:
46
+ WTBridgeRNA177nt.check_core_match(target, donor)
47
+ except errors.CoreMismatchError as e:
48
+ print("ERROR:", e)
49
+ print("Exiting...")
50
+ sys.exit()
51
+
52
+ try:
53
+ WTBridgeRNA177nt.check_target_is_dna(target)
54
+ except errors.TargetNotDNAError as e:
55
+ print("ERROR:", e)
56
+ print("Exiting...")
57
+ sys.exit()
58
+
59
+ try:
60
+ WTBridgeRNA177nt.check_donor_is_dna(donor)
61
+ except errors.DonorNotDNAError as e:
62
+ print("ERROR:", e)
63
+ print("Exiting...")
64
+ sys.exit()
65
+
66
+ brna = run.design_bridge_rna(target, donor)
67
+ if output_format == "fasta":
68
+ print(brna.format_fasta(include_annealing_oligos=include_annealing_oligos,
69
+ lh_overhang=annealing_oligos_lh_overhang,
70
+ rh_overhang=annealing_oligos_rh_overhang))
71
+ elif output_format == "stockholm":
72
+ print(brna.format_stockholm())
73
+
74
+
75
+ if __name__ == '__main__':
76
+ cli()
data/bridgernadesigner/run.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from bridgernadesigner.classes import WTBridgeRNA177nt
2
+ from bridgernadesigner import errors
3
+
4
+ def design_bridge_rna(target, donor):
5
+
6
+ target = target.upper()
7
+ donor = donor.upper()
8
+
9
+ WTBridgeRNA177nt.check_target_length(target)
10
+ WTBridgeRNA177nt.check_donor_length(donor)
11
+ WTBridgeRNA177nt.check_core_match(target, donor)
12
+ WTBridgeRNA177nt.check_target_is_dna(target)
13
+ WTBridgeRNA177nt.check_donor_is_dna(donor)
14
+
15
+ brna = WTBridgeRNA177nt()
16
+ brna.update_target(target)
17
+ brna.update_donor(donor)
18
+ brna.update_hsg()
19
+
20
+ return brna
21
+
data/setup.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from setuptools import setup, find_packages
2
+ import os
3
+
4
+ with open('README.md') as f:
5
+ long_description = f.read()
6
+
7
+ setup(
8
+ name="bridgernadesigner",
9
+ version='0.0.1',
10
+ description='Software package to design bridge RNAs as described by Durrant & Perry et al. 2024',
11
+ long_description=long_description,
12
+ long_description_content_type="text/markdown",
13
+ url='https://github.com/hsulab-arc/BridgeRNADesigner',
14
+ author="Matt Durrant",
15
+ author_email="matthew@arcinstitute.org",
16
+ license="MIT",
17
+ packages=find_packages(),
18
+ install_requires=[
19
+ 'biopython',
20
+ 'click==7.0'
21
+ ],
22
+ zip_safe=False,
23
+ entry_points = {
24
+ 'console_scripts': [
25
+ 'brna-design = bridgernadesigner.main:cli'
26
+ ]
27
+ }
28
+ )