Exemple #1
0
                    help="indices of atoms to consider")
args = parser.parse_args()
#######################################

refs = args.ref

# convert references into lists of coordinates
if refs[0].split(".")[-1] == "npy":
    refs = [npy3to2(np.load(r)) for r in refs]
else:
    coors = []
    for r in refs:
        ll = [l for l in open(r).readlines() if l.startswith("ATOM")]
        coor = [[float(l[30:38]),
                 float(l[38:46]),
                 float(l[46:54])] for l in ll]
        coors.append(coor)
    refs = np.array(coors)

npy = npy2to3(np.load(args.npy))
nat = np.shape(npy)[1]
selatoms = range(nat)
if args.atoms:
    selatoms = [int(i) - 1 for i in args.atoms]

rmsds = rmsdnpy(npy, refs, selatoms)
rmsd = np.min(rmsds, axis=1)

for i in range(len(rmsd)):
    print('%i %.2f' % (i + 1, rmsd[i]))
Exemple #2
0
parser.add_argument('--postatoms',
                    nargs='+',
                    help="frag1-postatoms.npy frag2-postatoms.npy ...")
parser.add_argument('--rmsd',
                    nargs='+',
                    help="frag1.rmsd frag2.rmsd ...",
                    default=None)

args = parser.parse_args()
############

tree = json.load(open(args.graph))
max_meanrank = float(args.meanrank)
nfrag = tree["nfrags"]

postatoms = [npy2to3(np.load(f)) for f in args.postatoms]
preatoms = [npy2to3(np.load(f)) for f in args.preatoms]

meanrank_threshold = log(max_meanrank) * nfrag

lrmsds = []
if args.rmsd is not None:
    for f in args.rmsd:
        lrmsd = {}
        lnr = 0
        for l in open(f):
            lnr += 1
            ll = l.split()
            if len(ll) != 2: continue
            k = ll[0]
            if k == "l-RMSD": k = lnr
Exemple #3
0
    RMSD = np.array([[(sum([(a1[i] - b1[i])**2
                            for i in range(ncoord)]) / (ncoord / 3))**0.5
                      for b1 in b] for a1 in a])
    return RMSD


assert len(
    sys.argv) == 3, "usage: python rmsdnpy.py npy.npy Lboundr.pdb > outp"

npyfile = sys.argv[1]  # npy.npy
if sys.argv[2].split(".")[-1] == "npy":
    ref = np.load(sys.argv[2])
    if len(ref.shape) > 2:
        assert ref.shape[2] == 3
        ref = ref.reshape((ref.shape[1], 3))
else:
    pdb = sys.argv[2]  # Lboundr.pdb
    ll = [l for l in open(pdb).readlines() if l.startswith("ATOM")]
    r = [[float(l[30:38]), float(l[38:46]), float(l[46:54])] for l in ll]
    ref = np.array(r)

npy = npy2to3(np.load(npyfile))
nat = np.shape(npy)[1]
selatoms = range(nat)
if len(sys.argv) > 3:
    selatoms = [int(i) - 1 for i in sys.argv[3:]]

RMSD = rmsdnpy(npy, ref, selatoms)
for i in range(len(RMSD)):
    print('%i %.2f' % (i + 1, RMSD[i]))
Exemple #4
0
#!/usr/bin/env python3
# Copyright Sjoerd J. De Vries (INSERM)

import sys, os
import numpy as np
from npy import npy2to3

npy = npy2to3(np.load(sys.argv[1]))
assert npy.ndim == 3, npy.ndim
pdb = sys.argv[2]
outpf = sys.argv[3]

dirname = os.path.dirname(os.path.abspath(__file__))


def read_forcefield(forcefieldfile):
    ff = {}
    aa = None
    for l in open(forcefieldfile):
        pound = l.find("#")
        if pound > -1: l = l[:pound]
        l = l.strip()
        if not len(l): continue
        ll = l.split()
        if len(ll) == 1:
            aa = ll[0]
            assert len(aa) <= 3, l
            ff[aa] = []
        else:
            assert aa is not None
            try:
try:
    steps = np.loadtxt(chainfile, dtype=int) - 1  ### changed 9-02_17:30
    if len(steps.shape) == 1:
        steps = np.reshape(steps, (1, steps.shape[0]))
except:
    print("no np.loadtxt")
    cc = [[int(i) - 1 for i in l.split()] for l in open(chainfile)]
    steps = np.array(cc)

nfrag = steps.shape[1]
nat = args.nat
print(nat, file=sys.stderr)

assert nfrag == len(nat) + 1, (nfrag, len(nat))

coor = [npy2to3(np.load(i)) for i in args.coor]  # one np.array per step

outp = args.outp
assert outp != args.chains_file, "ERROR: output is same as input"

#initialise merged structure
max_atom = sum([n.shape[1] for n in coor])  #max nb of atoms in final chain
rna = np.zeros((len(steps), max_atom, 3))
count = 0

#First atoms unchanged
len_step = coor[0].shape[1]  #nb of atoms in 1st step
n = len_step - nat[0]  #nb of atom to not merge in 1st step
rna[:, :n] = coor[0][steps[:, 0], :n]
count += n