Beispiel #1
0
def all_vs_all(filename='rms_matrix.txt'):
  AllObj=cmd.get_names("public_objects") # not temps created by alignment or selections
  matrix = []
  for x in AllObj:
    x_to_all = []
    for y in AllObj:
      rmsd = cmd.rms( x, y, cutoff=10)#[0] # super-inclusive
      x_to_all.append(rmsd)
    matrix.append(x_to_all)
  print matrix
  outfile = open(filename,'w')
  # No names 'on top' -- we can figure these out from the vertical ordering
  # and they're way too long...
  #for name in AllObj:
  #  outfile.write("\t%s" % name)
  #outfile.write("\n")
  maxlen = 0
  for obj in AllObj:
    if maxlen < len(obj):
      maxlen = len(obj)

  print_allobj = []
  for obj in AllObj:
    while len(obj) < maxlen:
      obj += ' '
    print_allobj.append(obj)
  ni = 0
  for x in matrix:
    outfile.write(print_allobj[ni])
    ni += 1
    for y in x:
      outfile.write("\t%0.2f" % y)
    outfile.write("\n")
Beispiel #2
0
 def testFit(self):
     cmd.fragment("gly", "m1")
     cmd.create("m2", "m1")
     rms = cmd.fit("m1", "m2")
     self.assertEqual(rms, 0.0)
     rms = cmd.rms("m1", "m2")
     self.assertEqual(rms, 0.0)
     rms = cmd.rms_cur("m1", "m2")
     self.assertEqual(rms, 0.0)
Beispiel #3
0
 def testFit(self):
     cmd.fragment("gly", "m1")
     cmd.create("m2", "m1")
     rms = cmd.fit("m1", "m2")
     self.assertEqual(rms, 0.0)
     rms = cmd.rms("m1", "m2")
     self.assertEqual(rms, 0.0)
     rms = cmd.rms_cur("m1", "m2")
     self.assertEqual(rms, 0.0)
Beispiel #4
0
def ens_rmsd(ens_selection,
             ref_selection,
             log_name = None):
    '''
DESCRIPTION

    Prints RMSD per structure in ensemble w.r.t. a reference structure

USAGE

    ens_rmsd ensemble_selection, reference_selection, name, log,

ARGUMENTS

    log = name of log file
    verbose = calculates structure by structure RMSD for ensemble w.r.t. a single reference structure

 EXAMPLE

    ens_rmsd ensemble_selection, reference_selection, name = 'rmsd', log 'ens.log'
  '''

    if log_name == None:
      log = LogWriter(sys.stdout, 'log.txt')
    else:
      log = LogWriter(sys.stdout, log_name+'.txt')

    # initialize arrays
    ens_selection = ens_selection + ' and not resn hoh'
    ref_selection = ref_selection + ' and not resn hoh'
    rmsd_states = []
    mean_coords = None
    number_models = cmd.count_states(ens_selection)

    # get models, mean coords
    print >> log, '\nRMSD by state'
    print >> log, '\n State | RMSD'
    for i in range(number_models):
      ens_coords = cmd.get_model(ens_selection,state=i+1).get_coord_list()
      ref_coords = cmd.get_model(ref_selection,state=1).get_coord_list()
      atom_sqr_dev = []
      for atom in xrange(len(ref_coords)):
        x = ref_coords[atom]
        y = ens_coords[atom]
        atom_sqr_dev.append(distance(x,y)**2)
      rmsd = math.sqrt(sum(atom_sqr_dev) / len(atom_sqr_dev))
      rmsd_states.append(rmsd)
      print >> log, ' %5d | %5.3f '%(i+1, rmsd)


    print_array_stats(array                 = rmsd_states,
                      log                   = log)
    print '\nRMSD all states : %5.3f '%(cmd.rms(ens_selection, ref_selection))
Beispiel #5
0
def rms_per_residue(sel1, sel2):
    atoms1 = get_atoms(sel1, ["chain", "resi"])
    atoms2 = get_atoms(sel2, ["chain", "resi"])

    resis1 = set(zip(atoms1.resi, atoms1.chain))
    resis2 = set(zip(atoms2.resi, atoms2.chain))

    labels = []
    values = []
    for resi, chain in resis1:
        labels.append(f"{resi}{chain}")
        values.append(
            pm.rms(
                f"({sel1}) and resi {resi} and chain {chain}",
                f"({sel2}) and resi {resi} and chain {chain}",
            ))
    ax = sb.lineplot(labels, values)
    ax.set_title("RMS per residue")
    ax.set_xticklabels(labels, rotation=45, ha="right")
    plt.show()
Beispiel #6
0
    cmd.create("trg", "ref", 1, a, quiet=0)
    cmd.alter_state(a, "trg", "x=x+random()/2")
    cmd.alter_state(a, "trg", "y=y+random()/2")
    cmd.alter_state(a, "trg", "z=z+random()/2", quiet=0)


cmd.frame(1)
print "%8.3f" % cmd.fit("ref", "trg")

# asdf


for a in xrange(1, 14):
    print a,
    print "%8.3f" % cmd.fit("ref and resi %d" % a, "trg"),
    print "%8.3f" % cmd.rms("ref", "trg"),
    print "%8.3f" % cmd.rms_cur("ref", "trg")

cmd.frame(10)

print "%8.3f" % cmd.fit("ref", "trg")
for a in xrange(1, 14):
    print a,
    print "%8.3f" % cmd.fit("ref and resi %d" % a, "trg"),
    print "%8.3f" % cmd.rms("ref", "trg"),
    print "%8.3f" % cmd.rms_cur("ref", "trg")


a = 1
print "%8.3f" % cmd.fit("ref", "trg")
for b in xrange(1, 11):
for a in xrange(1, 11):
    cmd.create("trg", "ref", 1, a, quiet=0)
    cmd.alter_state(a, "trg", "x=x+random()/2")
    cmd.alter_state(a, "trg", "y=y+random()/2")
    cmd.alter_state(a, "trg", "z=z+random()/2", quiet=0)

cmd.frame(1)
print "%8.3f" % cmd.fit("ref", "trg")

# asdf

for a in xrange(1, 14):
    print a,
    print "%8.3f" % cmd.fit("ref and resi %d" % a, "trg"),
    print "%8.3f" % cmd.rms("ref", "trg"),
    print "%8.3f" % cmd.rms_cur("ref", "trg")

cmd.frame(10)

print "%8.3f" % cmd.fit("ref", "trg")
for a in xrange(1, 14):
    print a,
    print "%8.3f" % cmd.fit("ref and resi %d" % a, "trg"),
    print "%8.3f" % cmd.rms("ref", "trg"),
    print "%8.3f" % cmd.rms_cur("ref", "trg")

a = 1
print "%8.3f" % cmd.fit("ref", "trg")
for b in xrange(1, 11):
    cmd._dump_floats(cmd.intra_fit("trg and resi %d" % a, b))
Beispiel #8
0
def align_rms(target1, target2):
    cmd.load(target1, "t1")
    cmd.load(target2, "t2")
    cmd.align("t1", "t2")
    return cmd.rms("t1 and resn unk", "t2 and resn unk")