def make_command(args): a = parser.parse_args(args) if a.pot == "usp": usp_pot = True else: usp_pot = False for source in a.source: task = NMRTask(source=source, num_cores=a.num_cores, queue=a.queue, xc_functional=a.xc_functional, cut_off_energy=a.cut_off_energy, usp_pot=usp_pot, pot_type=a.pot_type, efg_only=a.efg_only) source_dir, source_name = calc_from_path(source) target_dir = os.path.join(a.target_dir, source_name) if not os.path.isdir(target_dir): os.mkdir(target_dir) task.make(target_dir)
def get_cell(self): """ Make sure that self.cell is loaded, possibly by loading from source cell file. """ if self.cell is None and self.source is None: raise Exception("One of cell or source must be provided") if self.source is None and self.target_name is None: raise Exception("If no cell is provided, target_name must be specified") if self.source is not None: source_dir, self.source_name = calc_from_path(self.source) if self.cell is None: self.cell = Cell(os.path.join(source_dir, "{}.cell".format(self.source_name)))
def get_cell(self): """ Make sure that self.cell is loaded, possibly by loading from source cell file. """ if self.cell is None and self.source is None: raise Exception("One of cell or source must be provided") if self.source is None and self.target_name is None: raise Exception("If no cell is provided, target_name must be specified") if self.source is not None: source_dir, source_name = calc_from_path(self.source) if self.cell is None: self.cell = Cell(os.path.join(source_dir, "{}.cell".format(source_name)))
def test_success(self): for input, expected in self.tests_pass: self.assertEqual(utils.calc_from_path(input), expected)
if 'seeds' in structure: for seed in structure['seeds']: seed_map[seed] = structure_name couplings_map = {} to_mean = {} for magres_file in magres_files: print >>sys.stderr, magres_file try: atoms = MagresAtoms.load_magres(magres_file) except: continue dir, name = calc_from_path(magres_file) structure = None if name in seed_map: structure = data['structures'][seed_map[name]] elif name in data['structures']: structure = data['structures'][name] if structure is not None: couplings = structure['couplings'] # Go through each coupling in the structure and check if we want it. for atom in atoms: if hasattr(atom, 'isc'): for isc in atom.isc.values(): idx1 = "%s%d" % (isc.atom1.species, isc.atom1.index)
def make_command(args): a = parser.parse_args(args) print a.__dict__ sites = [] if a.site is not None: for site in a.site.split(","): sites.append(regex_species.findall(site)[0]) else: sites = [None] cut_off_energies = map(int, a.cut_off_energy.split(",")) xc_functionals = [s.lower() for s in a.xc_functional.split(",")] pots = a.pot.split(",") sources = a.source param_prod = list( itertools.product(sources, sites, cut_off_energies, xc_functionals, pots)) for source, site, cut_off_energy, xc_functional, pot in param_prod: source_dir, source_name = calc_from_path(source) # Set up following directory structure: # [rel/nrel]/[usp/ncp]/[xc_functional]/[structure]/[cutoff]/[site] dir_path = [a.target_dir] if len(pots) > 1: dir_path.append(pot) if len(xc_functionals) > 1: dir_path.append(xc_functional) if len(sources) > 1: dir_path.append(source_name) if len(cut_off_energies) > 1: dir_path.append("%dry" % cut_off_energy) if len(sites) > 1: dir_path.append("".join(site)) print dir_path new_dir = False for i in range(len(dir_path)): d = os.path.join(*dir_path[:i + 1]) if not os.path.isdir(d): os.mkdir(d) new_dir = True target_dir = os.path.join(*dir_path) if site is not None: jc_s, jc_i = site jc_i = int(jc_i) else: jc_s = None jc_i = None if pot == "usp": usp_pot = True elif pot == "ncp": usp_pot = False try: task = JcouplingTask(num_cores=a.num_cores, rel_pot=a.rel, usp_pot=usp_pot, xc_functional=xc_functional, cut_off_energy=cut_off_energy, queue=a.queue, jc_s=jc_s, jc_i=jc_i, source=source) task.make(target_dir) except JcouplingTask.SiteNotPresent, e: print e # If we've just made this directory, trash it if new_dir: shutil.rmtree(target_dir)
if 'seeds' in structure: for seed in structure['seeds']: seed_map[seed] = structure_name couplings_map = {} to_mean = {} for magres_file in magres_files: print >> sys.stderr, magres_file try: atoms = MagresAtoms.load_magres(magres_file) except: continue dir, name = calc_from_path(magres_file) structure = None if name in seed_map: structure = data['structures'][seed_map[name]] elif name in data['structures']: structure = data['structures'][name] if structure is not None: couplings = structure['couplings'] # Go through each coupling in the structure and check if we want it. for atom in atoms: if hasattr(atom, 'isc'): for isc in atom.isc.values(): idx1 = "%s%d" % (isc.atom1.species, isc.atom1.index)
def make_command(args): a = parser.parse_args(args) print a.__dict__ sites = [] if a.site is not None: for site in a.site.split(","): sites.append(regex_species.findall(site)[0]) else: sites = [None] cut_off_energies = map(int,a.cut_off_energy.split(",")) xc_functionals = [s.lower() for s in a.xc_functional.split(",")] pots = a.pot.split(",") sources = a.source param_prod = list(itertools.product(sources, sites, cut_off_energies, xc_functionals, pots)) for source,site,cut_off_energy,xc_functional,pot in param_prod: source_dir, source_name = calc_from_path(source) # Set up following directory structure: # [rel/nrel]/[usp/ncp]/[xc_functional]/[structure]/[cutoff]/[site] dir_path = [a.target_dir] if len(pots) > 1: dir_path.append(pot) if len(xc_functionals) > 1: dir_path.append(xc_functional) if len(sources) > 1: dir_path.append(source_name) if len(cut_off_energies) > 1: dir_path.append("%dry" % cut_off_energy) if len(sites) > 1: dir_path.append("".join(site)) print dir_path new_dir = False for i in range(len(dir_path)): d = os.path.join(*dir_path[:i+1]) if not os.path.isdir(d): os.mkdir(d) new_dir = True target_dir = os.path.join(*dir_path) if site is not None: jc_s, jc_i = site jc_i = int(jc_i) else: jc_s = None jc_i = None if pot == "usp": usp_pot = True elif pot == "ncp": usp_pot = False try: task = JcouplingTask(num_cores=a.num_cores, rel_pot=a.rel, usp_pot=usp_pot, xc_functional=xc_functional, cut_off_energy=cut_off_energy, queue=a.queue, jc_s=jc_s, jc_i=jc_i, source=source) task.make(target_dir) except JcouplingTask.SiteNotPresent, e: print e # If we've just made this directory, trash it if new_dir: shutil.rmtree(target_dir)