Exemple #1
0
def read_enestruc(datfile):
    header,structures = read_struc(datfile)
    structures = list(structures)
    energies = []
    for l1,l2 in structures:
      for ll in l1:
        if ll.startswith("## Energy:"):
          ee = ll[10:].strip()
          if ee.startswith("nan"):
            e = 99999999999999
          else:
            e = float(ee)
          energies.append(e)
    energies4 = energies[:4]
    energy = sum(energies4)/len(energies4)
    return header, energy, energies, structures
Exemple #2
0
        raise Exception(
            "Please supply an even number of PDB files (unbound, bound)")

    unboundfiles = []
    boundfiles = []
    for n in range(2, len(sys.argv), 2):
        unboundfiles.append(sys.argv[n])
        boundfiles.append(sys.argv[n + 1])

    if len(boundfiles) == 1 and opt_allresidues == False:
        raise Exception("Cannot determine the interface for a single PDB")

    bounds = [rmsdlib.read_pdb(f) for f in boundfiles]
    unbounds = [rmsdlib.read_pdb(f) for f in unboundfiles]

    struc_header, structures = read_struc(sys.argv[1])
    pivots = []
    for hnr, h in enumerate(struc_header):
        if not h.startswith("#pivot"): continue
        hh = h.split()
        assert len(hh) == 5 and hh[1] == str(hnr + 1), h
        pivot = numpy.array([float(v) for v in hh[2:5]])
        pivots.append(pivot)

    initargs = [sys.argv[1]] + unboundfiles
    if modefile: initargs += ["--modes", modefile]
    if imodefile: initargs += ["--imodes", imodefile]
    for nr, ensfile in ensfiles:
        initargs += ["--ens", nr, ensfile]

    collectlib.collect_init(initargs)
Exemple #3
0
allboundatoms = []
boundatoms = []
for p in bounds:
    b = []
    for c in p.coordinates():
        allboundatoms.append(c)
        b.append(c)
    boundatoms.append(numpy.array(b))
allboundatoms = numpy.array(allboundatoms)

nstruc = 0
f1 = sys.stdout
if output is not None:
    f1 = open(output, 'w')
h, strucs = read_struc(sys.argv[1])
while 1:
    sys.stdout.flush()
    if name is not None:
        newargs = initargs + [
            '--imodes', 'flexm-' + str(nstruc + 1) + name + '.dat'
        ]
        if not os.path.exists('flexm-' + str(nstruc + 1) + name + '.dat'):
            break
        collectlib.collect_iattract(newargs)

    result = collectlib.collect_next()
    if result: break
    nstruc += 1

    l1, l2 = strucs.next()
Exemple #4
0
    sys.exit()

if score:
    for n in range(nrsplit):
        fnam = "%s-%d" % (sys.argv[1], n + 1)
        for l in open(fnam).readlines():
            assert not l.startswith("#")  #must be .score file, not .dat file!!
            print l,
    sys.exit()

allstructures = {}
maxstruc = 0
stnr = 0
for n in range(nrsplit):
    fnam = "%s-%d" % (sys.argv[1], n + 1)
    header0, structures = read_struc(fnam)
    if n == 0:
        for h in header0:
            print h
    currstruc = None
    currstruc_false = False
    for s in structures:
        stnr += 1
        l1, l2 = s
        print "#" + str(stnr)
        skipline = -1
        for lnr, l in enumerate(l1):
            if l.startswith("### SPLIT "):
                try:
                    currstruc = int(l[len("### SPLIT"):])
                except:
Exemple #5
0
def write_clustfile(clust, clustfile):
    cf = open(clustfile, "w")
    for cnr, c in enumerate(clust):
        print >> cf, "Cluster %d ->" % (cnr + 1),
        for cc in c:
            print >> cf, cc,
        print >> cf, ""


rootclusters = read_clustfile(clustfile)

tmpfd, tmpnam = tempfile.mkstemp(text=True)
tmpf = os.fdopen(tmpfd, "w")
try:
    header, structures = read_struc(datfile)
    structures = list(structures)
    for h in header:
        print >> tmpf, h
    snr = 0
    for c in rootclusters:
        for cc in c:
            snr += 1
            print >> tmpf, "#%d" % snr
            s1, s2 = structures[cc - 1]
            for l in s2:
                print >> tmpf, l
    tmpf.close()

    assert snr == sum([len(c) for c in rootclusters
                       ]), (snr, sum([len(c) for c in rootclusters]))
Exemple #6
0
CLUST_MARGIN = 2  #2 is the theoretical worse case; change to 9999 to disable all effects of clustering
#CLUST_MARGIN = 9999

chicutoff = float(sys.argv[1])
chicutoffmin = chicutoff - 1.0
max_rmsd = float(sys.argv[2])
maxstruc = int(sys.argv[3])
max_msd = max_rmsd**2
maxclusterlevel = CLUSTERING.index(max_rmsd)
coor_structures = sys.argv[4]
coor_clusters = sys.argv[5]
chi_structures = sys.argv[6]
chi_clusters_filename = sys.argv[7]
dat_structures = sys.argv[8]
dat_clusters_filename = sys.argv[9]
header_structures, dof_structures = read_struc(dat_structures)
header_clusters, dof_clusters = read_struc(dat_clusters_filename)
dof_structures = list(dof_structures)
dof_clusters = list(dof_clusters)
coor_structures = np.load(coor_structures)
coor_clusters = np.load(coor_clusters)
chi_structures = np.load(chi_structures)
chi_clusters = np.load(chi_clusters_filename)
for a in coor_clusters, coor_structures:
    assert len(a.shape) == 2 and a.shape[1] % 3 == 0, a.shape

arr = [coor_structures, coor_clusters]
nstruc = []
for anr, a in enumerate(arr):
    ncoor = a.shape[1] / 3
    arr[anr] = a.reshape(a.shape[0], ncoor, 3)
Exemple #7
0
#replaces ligand N in .dat file 1 with ligand N in .dat file 2. .dat file 2 must contain a single structure
import sys
from math import *
from _read_struc import read_struc
import itertools

ligand = int(sys.argv[1])
header, structures2 = read_struc(sys.argv[3])
structures2 = list(structures2)
assert len(structures2) == 1, sys.argv[3]
other = structures2[0]
assert ligand <= len(other[1])

header, structures = read_struc(sys.argv[2])

stnr = 0
for h in header:
    print h
for s in structures:
    assert len(s[1]) == len(other[1])
    stnr += 1
    print "#" + str(stnr)
    for l in s[0]:
        print l
    for vnr, v in enumerate(s[1]):
        if vnr + 1 == ligand:
            print other[1][vnr]
        else:
            print s[1][vnr]
start = 0
if options.fix_receptor: start = 1
dori = options.ori
dtrans = options.trans
dmode = options.mode
clone = options.clone
keepfirst = options.keepfirst

random.seed(options.seed)

import sys
from _read_struc import read_struc
import random
from math import *

header, structures = read_struc(args[0])

for h in header:
    print h
stnr = 0
for s in structures:
    clonenr = 0
    while 1:
        stnr += 1
        l1, l2 = s
        l1, l2 = list(l1), list(l2)  #copy
        for lnr in range(start, len(l2)):
            l = l2[lnr]
            values = [float(v) for v in l.split()]
            is_morph, is_ens = False, False
            if lnr + 1 in morph: is_morph = True