@@ 218-275 (lines=58) @@ | ||
215 | print(p, '', [i + 1 for i in p], end=' ') |
|
216 | print(seq, 'seq_min: ' + seq_min, rms) |
|
217 | ||
218 | if p_min: # found target sequence |
|
219 | # what is this? ;-) |
|
220 | index = [0 ,0 ,0] |
|
221 | index[0] = p_min.index(0) |
|
222 | index[1] = p_min.index(1) |
|
223 | index[2] = p_min.index(2) |
|
224 | ||
225 | # ugly re-set 123 to crazy id ! + 100, so this will |
|
226 | # fill up 1 2 3 for the second for |
|
227 | rs = other_rnamodel.struc[0].get_residues() |
|
228 | for i, r in enumerate(rs): |
|
229 | r.id = (' ', index[i] + 253, ' ') # ugly, some random offset |
|
230 | ||
231 | for i, r in enumerate(other_rnamodel.struc[0].get_residues()): |
|
232 | r.id = (' ', index[i] + 1, ' ') |
|
233 | if args.debug: print('r', r) |
|
234 | ||
235 | io = Bio.PDB.PDBIO() |
|
236 | sup_min.apply(other_rnamodel.struc.get_atoms()) |
|
237 | # if args.debug: print(p_min, [i + 1 for i in p_min]) |
|
238 | io.set_structure(other_rnamodel.struc) |
|
239 | ||
240 | args.save_here = True |
|
241 | if args.save_here and save: |
|
242 | folder = os.path.basename(self.fpath.replace('.pdb', '_' + args.folder_prefix + '_aligned')) |
|
243 | # print(f) |
|
244 | try: |
|
245 | os.mkdir(folder) |
|
246 | except: |
|
247 | pass |
|
248 | fout = folder + os.sep + "{:1.2f}".format(rmsd_min) + '-' + os.path.basename(other_rnamodel.fpath)#.replace('.pdb', '-' + str(rms) + '.pdb')) |
|
249 | #_s' + suffix + '.pdb')) |
|
250 | else: |
|
251 | fout = other_rnamodel.fpath.replace('.pdb', '_aligned.pdb')#_s' + suffix + '.pdb') |
|
252 | ||
253 | if args.debug: print(fout) |
|
254 | ||
255 | if save: |
|
256 | io.save(fout) |
|
257 | # ugly set chain to A |
|
258 | set_chain_for_struc(fout, 'A', save_file_inplace=True) |
|
259 | # and now run this to sort into 1 2 3 |
|
260 | ||
261 | r = RNAStructure(fout) |
|
262 | remarks = r.get_remarks_text() |
|
263 | r1 = r.get_res_text('A', 1) |
|
264 | r2 = r.get_res_text('A', 2) |
|
265 | r3 = r.get_res_text('A', 3) |
|
266 | with open(fout, 'w') as f: |
|
267 | f.write(remarks) |
|
268 | f.write(r1) |
|
269 | f.write(r2) |
|
270 | f.write(r3) |
|
271 | r.reload() |
|
272 | r.get_rnapuzzle_ready() |
|
273 | if rmsd_min < 1: # !!!!!!!!!!!! ugly |
|
274 | r.write() |
|
275 | return str(rmsd_min)# + ',s' + seq_min + ',' + os.path.basename(fout) |
|
276 | else: |
|
277 | # check if number of the same atoms # |
|
278 | # if not the same then return -1 # |
@@ 159-216 (lines=58) @@ | ||
156 | print(p, '', [i + 1 for i in p], end=' ') |
|
157 | print(seq, 'seq_min: ' + seq_min, rms) |
|
158 | ||
159 | if p_min: # found target sequence |
|
160 | # what is this? ;-) |
|
161 | index = [0 ,0 ,0] |
|
162 | index[0] = p_min.index(0) |
|
163 | index[1] = p_min.index(1) |
|
164 | index[2] = p_min.index(2) |
|
165 | ||
166 | # ugly re-set 123 to crazy id ! + 100, so this will |
|
167 | # fill up 1 2 3 for the second for |
|
168 | rs = other_rnamodel.struc[0].get_residues() |
|
169 | for i, r in enumerate(rs): |
|
170 | r.id = (' ', index[i] + 253, ' ') # ugly, some random offset |
|
171 | ||
172 | for i, r in enumerate(other_rnamodel.struc[0].get_residues()): |
|
173 | r.id = (' ', index[i] + 1, ' ') |
|
174 | if args.debug: print('r', r) |
|
175 | ||
176 | io = Bio.PDB.PDBIO() |
|
177 | sup_min.apply(other_rnamodel.struc.get_atoms()) |
|
178 | # if args.debug: print(p_min, [i + 1 for i in p_min]) |
|
179 | io.set_structure(other_rnamodel.struc) |
|
180 | ||
181 | args.save_here = True |
|
182 | if args.save_here and save: |
|
183 | folder = os.path.basename(self.fpath.replace('.pdb', '_' + args.folder_prefix + '_aligned')) |
|
184 | # print(f) |
|
185 | try: |
|
186 | os.mkdir(folder) |
|
187 | except: |
|
188 | pass |
|
189 | fout = folder + os.sep + "{:1.2f}".format(rmsd_min) + '-' + os.path.basename(other_rnamodel.fpath)#.replace('.pdb', '-' + str(rms) + '.pdb')) |
|
190 | #_s' + suffix + '.pdb')) |
|
191 | else: |
|
192 | fout = other_rnamodel.fpath.replace('.pdb', '_aligned.pdb')#_s' + suffix + '.pdb') |
|
193 | ||
194 | if args.debug: print(fout) |
|
195 | ||
196 | if save: |
|
197 | io.save(fout) |
|
198 | # ugly set chain to A |
|
199 | set_chain_for_struc(fout, 'A', save_file_inplace=True) |
|
200 | # and now run this to sort into 1 2 3 |
|
201 | ||
202 | r = RNAStructure(fout) |
|
203 | remarks = r.get_remarks_text() |
|
204 | r1 = r.get_res_text('A', 1) |
|
205 | r2 = r.get_res_text('A', 2) |
|
206 | r3 = r.get_res_text('A', 3) |
|
207 | with open(fout, 'w') as f: |
|
208 | f.write(remarks) |
|
209 | f.write(r1) |
|
210 | f.write(r2) |
|
211 | f.write(r3) |
|
212 | r.reload() |
|
213 | r.get_rnapuzzle_ready() |
|
214 | if rmsd_min < 1: # !!!!!!!!!!!! ugly |
|
215 | r.write() |
|
216 | return str(rmsd_min)# + ',s' + seq_min + ',' + os.path.basename(fout) |
|
217 | else: |
|
218 | # check if number of the same atoms # |
|
219 | # if not the same then return -1 # |