def run(infile, prefix, covariance):
  # read in pdb file (parmed)
  pdb = read_PDB(infile)
  if covariance:
    A = set_A(pdb, covariance=covariance)
    # set B
    B = set_B(pdb, covariance=covariance)
  else:
    # set A
    A = set_A(pdb, covariance=covariance)
    # set B
    B = set_B(pdb, covariance=covariance)
  import code; code.interact(local=dict(globals(), **locals()))
  # solve Ax=B
  x = solve_SVD(A,B)
  # calc new ADP and residual and print residual
  UTLS, TLS_residual = calc_ADP_from_TLS(x,A,B)
  print "The ADP TLS residual is %6.4f." %TLS_residual
  # write tls file
  write_TLS(x, prefix)

  # write out pdb file(parmed) plug in UTLS
  out_pdb = pdb
  # for i,atom in enumerate(atomlist):
  #   for Uij in range(6):
  #   atom.UIJ[Uij] = UTLS[i*6+Uij]
  # calculate iso Bfactor from Uij (matlab)
  write_PDB(out_pdb, "%s.pdb" %prefix)
Beispiel #2
0
def run(infile, prefix, covariance_file):
  # read in pdb file (parmed)
  pdb = read_PDB(infile)
  assert pdb.box is not None, "ERROR: CRYST1 record required in PDB file!"
  # get centroid
  com = center_of_mass(pdb)

  if not covariance_file:
    # set A
    A = set_A(pdb, com)
    # set B
    B = set_B(pdb)
    # solve Ax=B
    x = solve_SVD(A,B)
    # calc new ADP and residual and print residual
    UTLS, SSE, MSE, r2 = calc_ADP_from_TLS(x,A,B)
    

  else:
    # expanded A with 6*n(n-1)/2-3n equations
    A_cov = set_A_cov(pdb, com)
    # 6*n(n-1)/2-3n covariances
    B_cov, uu = set_B_cov(pdb, covariance_file)
    # 21 TLS parameters
    x = solve_SVD(A_cov, B_cov)

    # calc new ADP and residual and print residual
    UTLS, SSE, MSE, r2 = calc_ADP_from_TLS_cov(pdb, com, uu, x)
  
  #print statistics
  print "     *** ADP FIT STATISTICS ***"
  print "The ADP Sum of Squared Errors is %6.4f." %SSE
  print "The ADP Mean Squared Error is %6.4f." %MSE
  print "The ADP R-square statistic is %6.4f." %r2
  
  # populate TLS matrices
  T,L,S = set_TLS(x)

  # shift TLS to center of reaction
  T,L,S,cor = center_of_reaction_shift(T,L,S, com)

  # write TLS to file
  write_TLS(T,L,S,cor,pdb, prefix)

  # import code; code.interact(local=dict(globals(), **locals()))
  # import sys; sys.exit()

  # write out pdb file with new ADP/Bfactors
  for i,atom in enumerate(pdb.atoms):
     atom.anisou = UTLS[i*6:i*6+6]
     Bfac, Ueq = Adp2B(np.array(pdb.box),atom.anisou, method=2)
     atom.bfactor = Bfac
  write_PDB(pdb, "%s.pdb" %prefix, write_anisou=True)
  return 0