-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresFileStructureComparison.py
More file actions
51 lines (42 loc) · 1.94 KB
/
Copy pathresFileStructureComparison.py
File metadata and controls
51 lines (42 loc) · 1.94 KB
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
''' Run this script as python resFileStructureComparion.py [res file 1] [res file 2]
If needed export PYTHONPATH='/home/dcase/davesScripts':$PYTHONPATH
export CSDHOME=/etc/CCDC/CSD_2017/
export LD_LIBRARY_PATH=/usr/local/lib/python2.7/dist-packages/ccdc/_lib:$LD_LIBRARY_PATH '''
from ccdc.io import CrystalReader
from ccdc.crystal import PackingSimilarity
import sys
def returnNmatched_molecules(comparisonObject, crystal1, crystal2, returnRMSD=False):
''' All inputs are CCDC objects - this really just catches fails
Copied from davesScripts to save importing '''
compareResult = comparisonObject.compare(crystal1, crystal2)
if returnRMSD:
try:
return compareResult.nmatched_molecules, compareResult.rmsd
except:
return None, None
else:
try:
return compareResult.nmatched_molecules
except:
return None
# Set up comparison object
ps = PackingSimilarity()
allowMolecularDifferences = True
clusterSize = 15
ps.settings.allow_molecular_differences = allowMolecularDifferences
ps.settings.packing_shell_size = clusterSize
# define crystals
try:
crystal1 = CrystalReader(sys.argv[1], format='res')[0]
except:
crystal1 = CrystalReader(sys.argv[1], format='cif')[0]
try:
crystal2 = CrystalReader(sys.argv[2], format='res')[0]
except:
crystal2 = CrystalReader(sys.argv[2], format='cif')[0]
matchingData = returnNmatched_molecules(ps, crystal1, crystal2, returnRMSD=True)
#print "Matching {1} molecules (out of {2}) with RMSD = {3} Angstroms".format(clusterSize,clusterSize,clusterSize)
print "Allowing molecular differences? ", allowMolecularDifferences
print "Matching %s molecules (out of %s) with RMSD = %s Angstroms"%(matchingData[0],
clusterSize,
matchingData[1])