forked from RuzickaJiri/Pores
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatch.py
113 lines (94 loc) · 3.51 KB
/
batch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 19 2019
@author: jruzicka
"""
# Librairies
import os
import shutil
import analysis as an
import script as sc
def mole_basic(l, start, end):
"""
mole 2.5 computation of given pdb entries between the two positions, basic mode
:param l: list od pdb ids
:param start: starting position
:param end: ending position
"""
pores_trunc = l[start:end]
for pdbid in pores_trunc:
try:
os.mkdir("D:\calculation\jiri\mole_pores\\" + pdbid)
os.popen("D:\\calculation\\jiri\\Pores\\Pores.exe ""D:\calculation\jiri\mole_pores\\" + pdbid + ".json")
except :
print(pdbid)
def mole_tm(l, start, end):
"""
mole 2.5 computation of given pdb entries between the two positions, TM mode
:param l: list od pdb ids
:param start: starting position
:param end: ending position
"""
pores_trunc = l[start:end]
for pdbid in pores_trunc:
try:
os.mkdir("D:\calculation\jiri\mole_pores\\" + pdbid + "_TM")
os.popen("D:\\calculation\\jiri\\Pores\\Pores.exe ""D:\calculation\jiri\mole_pores\\" + pdbid + "_TM.json")
except FileExistsError:
print(pdbid + "_TM")
def get_exist(path):
"""
verifies if given path exists
:param path: path to be verified
:return: binary
"""
return os.path.exists(path + "\\json")
def get_list_exist(path, l):
"""
finds the entries for which the computation was not successful, basic mode
:param path: given path
:param l: list of pdb ids
:return: tuple (number of non existing computations, its list)
"""
does_not = 0
pdb_list = []
for pdbid in l:
if not get_exist(path + pdbid):
does_not += 1
pdb_list.append(pdbid)
return does_not, pdb_list
def get_list_exist_tm(path, l):
"""
finds the entries for which the computation was not successful, TM mode
:param path: given path
:param l: list of pdb ids
:return: tuple (number of non existing computations, its list)
"""
does_not = 0
pdb_list = []
for pdbid in l:
if not get_exist(path + pdbid + "_TM"):
does_not += 1
pdb_list.append(pdbid)
return does_not, pdb_list
if __name__ == "__main__":
with open('pdbid_to_mole_fromTM.txt') as f: # get the list of pores
my_pores_to_moleTM = f.readlines()
for i in range(len(my_pores_to_moleTM)):
my_pores_to_moleTM[i] = my_pores_to_moleTM[i].rstrip('\n')
print(my_pores_to_moleTM)
# an.generate_mole_jsons("D:\calculation\jiri\mole_pores\\", False, my_pores_to_mole)
# an.download_all_cif(my_pores_to_mole)
# mole_basic(my_pores_to_moleTM, 0, 38)
with open('pdbid_to_mole.txt') as f: # get the list of pores
my_pores_to_mole = f.readlines()
for i in range(len(my_pores_to_mole)):
my_pores_to_mole[i] = my_pores_to_mole[i].rstrip('\n')
print(my_pores_to_mole)
# an.generate_mole_jsons("D:\calculation\jiri\mole_pores\\", False, my_pores_to_mole)
# an.download_all_cif(my_pores_to_mole)
# mole_basic(my_pores_to_mole, 0, 976)
print(len(my_pores_to_mole+my_pores_to_moleTM))
print(get_list_exist("D:\calculation\jiri\mole_pores\\", my_pores_to_mole+my_pores_to_moleTM))
redo = get_list_exist("D:\calculation\jiri\mole_pores\\", my_pores_to_mole+my_pores_to_moleTM)[1]