-
Notifications
You must be signed in to change notification settings - Fork 6
/
nmrutil.py
52 lines (47 loc) · 2.32 KB
/
nmrutil.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
import configparser
import os
def readprops(project=""):
result={}
cp = configparser.SafeConfigParser()
cp.readfp(open('nmrproc.properties'))
for (each_key, each_val) in cp.items('onesectiononly'):
result[each_key]=each_val
datapath=cp.get('onesectiononly', 'datadir')
if not project=="" and os.path.exists(datapath+os.sep+project+os.sep+'nmrproc.properties'):
cp2 = configparser.SafeConfigParser()
cp2.readfp(open(datapath+os.sep+project+os.sep+'nmrproc.properties'))
for (each_key, each_val) in cp2.items('onesectiononly'):
result[each_key]=each_val
return result
def checkprojectdir(datapath, project, cp):
if not os.path.exists(datapath+os.sep+project):
print("There is no directory "+datapath+os.sep+project+" - please check!")
if os.path.exists(datapath+os.sep+project+os.sep+"result"):
predictionoutputfile=datapath+os.sep+project+os.sep+'result'+os.sep+cp.get('predictionoutput')
if os.path.exists(predictionoutputfile):
os.remove(predictionoutputfile)
clusteringoutputfile=datapath+os.sep+project+os.sep+'result'+os.sep+cp.get('clusteringoutput')
if os.path.exists(clusteringoutputfile):
os.remove(clusteringoutputfile)
louvainoutputfile=datapath+os.sep+project+os.sep+'result'+os.sep+cp.get('louvainoutput')
if os.path.exists(louvainoutputfile):
os.remove(louvainoutputfile)
predictionoutputfile=datapath+os.sep+project+os.sep+'result'+os.sep+cp.get('predictionoutput')+'hsqc'
if os.path.exists(predictionoutputfile):
os.remove(predictionoutputfile)
predictionoutputfile=datapath+os.sep+project+os.sep+'result'+os.sep+cp.get('predictionoutput')+'hmbc'
if os.path.exists(predictionoutputfile):
os.remove(predictionoutputfile)
predictionoutputfile=datapath+os.sep+project+os.sep+'result'+os.sep+cp.get('predictionoutput')+'hsqctocsy'
if os.path.exists(predictionoutputfile):
os.remove(predictionoutputfile)
else:
os.mkdir(datapath+os.sep+project+os.sep+"result")
if not os.path.exists(datapath+os.sep+project+os.sep+"result"+os.sep+"smart"):
os.mkdir(datapath+os.sep+project+os.sep+"result"+os.sep+"smart")
if os.path.exists(datapath+os.sep+project+os.sep+"plots"):
for f in os.listdir(datapath+os.sep+project+os.sep+"plots"):
if f.endswith(".png"):
os.remove(os.path.join(datapath+os.sep+project+os.sep+"plots", f))
else:
os.mkdir(datapath+os.sep+project+os.sep+"plots")