Esempio n. 1
0
def process(pdb_files, nmax, rmax=50.0, fraction=0.9):
    pdb_models = []
    rmax_over_fraction = rmax / fraction
    shift = (rmax_over_fraction, rmax_over_fraction, rmax_over_fraction)
    for file in pdb_files:
        mom_obj, vox_obj, ipdb = pdb2zernike.zernike_moments(
            file, nmax=nmax, coef_out=False, calc_intensity=False)
        pdb_rmax = vox_obj.rmax()
        if (vox_obj.rmax() < rmax):
            mom_obj, vox_obj, ipdb = pdb2zernike.zernike_moments(
                file,
                nmax=nmax,
                external_rmax=rmax,
                coef_out=False,
                calc_intensity=False)
        if (mom_obj is not None):
            if (len(pdb_models) == 0):
                ref_nlm_array = mom_obj.moments()
                pdb_models.append(
                    pdb_model(mom_obj.moments().coefs(), file, pdb_rmax, ipdb))
                ea = (0, 0, 0)
                write_pdb(file, vox_obj, ea, shift, ipdb)
            else:
                mov_nlm_array = mom_obj.moments()
                align_obj = fft_align.align(ref_nlm_array,
                                            mov_nlm_array,
                                            nmax=nmax,
                                            refine=True)
                pdb_models.append(
                    pdb_model(align_obj.moving_nlm.coefs(), file, pdb_rmax,
                              ipdb))
                ea = align_obj.best_ea
                write_pdb(file, vox_obj, ea, shift, ipdb)
    return pdb_models
Esempio n. 2
0
def run(args, log=sys.stdout):
  params = get_input( args, master_params, "fxs_znk", banner, print_help )
  if (params is None):
    exit()
  nmax=params.fxs_znk.nmax
  lmax=params.fxs_znk.lmax
  if (lmax is None): lmax=nmax
  np_on_grid=params.fxs_znk.np_on_grid
  filename =params.fxs_znk.pdb
  output = params.fxs_znk.output
  fix_dx=params.fxs_znk.fix_dx
  q_array = None
  if q_array is None:
     q_array = params.fxs_znk.q_start +  \
               (params.fxs_znk.q_stop-params.fxs_znk.q_start) \
               *flex.double( range(params.fxs_znk.n_step) )/(params.fxs_znk.n_step-1)

  mom_obj, vox_obj, pdb = pdb2zernike.zernike_moments( filename, nmax=nmax, \
                          np=np_on_grid, fix_dx=fix_dx, coef_out=False, calc_intensity=True)
  c_nlm = mom_obj.moments()
  rmax = vox_obj.rmax()/0.9
  znk_mom_variants = zernike_moment_variants( c_nlm, q_array, rmax, nmax, lmax )

  out = open(output,'w')
  this_blq = znk_mom_variants.get_all_blq2()
  blq_data = fxs_tools.blq_data(q_array,this_blq,lmax )
  blq_data.print_out(out=out)
  out.close()
Esempio n. 3
0
def run(args):
  params = get_input(args, master_params, "db", banner, help)
  if params is None:
    exit()
  path = params.db.path+"/"
  nmax=params.db.nmax
  np = params.db.np
  fix_dx = params.db.fix_dx
  prefix = params.db.prefix


  files = read(path)
  nlm_coefs = []
  nn_coefs = []
  codes = []
  rmax = []
  for file in files:
    code = file.split('\n')[0].split('.')[0]
    file = path+file
    mom_obj, vox_obj, pdb = pdb2zernike.zernike_moments( file, nmax=nmax, np=np, fix_dx=fix_dx, coef_out=False, calc_intensity=False )
    if(mom_obj is None):
      print code, "NOT processed, please check the file"
      continue
    codes.append( code )
    rmax.append( vox_obj.rmax() )
    nlm_coefs.append( mom_obj.moments().coefs().deep_copy() )
    nn_coefs.append( mom_obj.fnn().coefs().deep_copy() )
    print code, "processed."

  easy_pickle.dump(prefix+".nlm", nlm_coefs)
  easy_pickle.dump(prefix+".nn", nn_coefs)
  easy_pickle.dump(prefix+".rmax", rmax)
  easy_pickle.dump(prefix+".codes", codes)
Esempio n. 4
0
def tst(filename):
    nmax = 20
    np = 30
    fix_dx = True
    prefix = tst

    q_array = flex.double(range(50)) / 100.0
    mom_obj, vox_obj, pdb = pdb2zernike.zernike_moments(filename,
                                                        nmax=nmax,
                                                        np=np,
                                                        fix_dx=fix_dx,
                                                        coef_out=False,
                                                        calc_intensity=True)
    c_nlm = mom_obj.moments()
    rmax = vox_obj.rmax() / 0.9
    znk_mom_variants = zernike_moment_variants(c_nlm, q_array, rmax, nmax)

    this_blq = flex.double()
    for ii in range(50):
        real_coef = znk_mom_variants.get_real_coef(ii)
        print q_array[ii],
        for cc in real_coef:
            print cc,
            this_blq.append(cc)
        print
Esempio n. 5
0
def get_results( args ): # args = [path, filename, nmax, np, fix_dx]
  code = args[1].split('.')[0]
  file = args[0]+args[1]
  nmax=args[2]
  np = args[3]
  fix_dx = args[4]

  mom_obj, vox_obj, ipdb = pdb2zernike.zernike_moments( file, nmax=nmax, np=np, fix_dx=fix_dx, coef_out=False, calc_intensity=False )
  if( mom_obj is None):
    print code, "not processed, check the file"
    return None
  print code, "processed."
  return (mom_obj.moments().coefs(), mom_obj.fnn().coefs(), code, vox_obj.rmax() )
 def build_with_pdb(self, pdbfile):
   mom_obj, vox_obj, pdb_inp = pdb2zernike.zernike_moments(pdbfile, nmax=self.nmax, fix_dx=True, coef_out=False, calc_intensity=False)
   if( mom_obj is None):
     print "The file does not have coordinate info, please check", pdbfile
   else:
     self.nlm_array = mom_obj.moments()
     if( self.rmax is None ):
       self.rmax = vox_obj.rmax() / self.fraction
     self.vox_obj = vox_obj
     self.pdb_inp = pdb_inp
     oned_np = self.vox_obj.np()*2 + 1
     self.volume = self.rmax**3.0*8.0*self.vox_obj.occupied_sites()/( oned_np**3.0 )
   self.id = pdbfile.split('.')[0]