def test_iter_matches_guaianolide(): system = System.from_file(context.get_fn('test/guaianolide.xyz')) system.detect_bonds() system_ref = System.from_file(context.get_fn('test/guaianolide_framework_ordered.xyz')) system_ref.detect_bonds() order = np.array(system.iter_matches(system_ref).next()) np.testing.assert_equal(order, [8, 9, 4, 7, 14, 12, 11, 10, 5, 6, 13, 16, 15, 2, 0, 1, 3])
def test_iter_matches_single_atom(): system = System.from_file(context.get_fn('test/rhodium_complex_nobornane.xyz')) system.detect_bonds() system_ref = System(pos=np.zeros((1, 3), float), numbers = np.array([45])) system_ref.detect_bonds() selected = set(system.iter_matches(system_ref).next()) reference = set([28]) np.testing.assert_equal(selected, reference)
def test_iter_matches_nobornane_rhodium(): rules = [ ('H', '1'), ('C_H1', '6&=1%1'), ('C_H2', '6&=2%1'), ('C_H3', '6&=3%1'), ('C', '6'), # all remaining carbons ('P', '15'), ('Rh', '45'), ] system = System.from_file(context.get_fn('test/rhodium_complex_nobornane.xyz')) system.detect_bonds() system.detect_ffatypes(rules) system_ref = System.from_file(context.get_fn('test/nobornane.xyz')) system_ref.detect_bonds() system_ref.detect_ffatypes(rules) selected = set(system.iter_matches(system_ref).next()) reference = set([77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]) np.testing.assert_equal(selected, reference)
def run_example(workdir, command): env = dict(os.environ) if os.path.isfile('setup.py') and os.path.isdir('data') and os.path.isdir('yaff'): # Needed in case the tests are executed on an in-place build: rootdir = os.getcwd() env['PYTHONPATH'] = rootdir + ':' + env.get('PYTHONPATH', '') env['YAFFDATA'] = os.path.join(rootdir, 'data') workdir = context.get_fn(workdir) proc = subprocess.Popen(shlex.split(command), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=workdir, env=env) outdata, errdata = proc.communicate() if proc.returncode != 0: print 'Standard output' print '+'*80 print outdata print '+'*80 print 'Standard error' print '+'*80 print errdata print '+'*80 assert False fn_clean = os.path.join(workdir, 'clean.sh') if os.path.isfile(fn_clean): assert os.system('cd %s; ./clean.sh &> /dev/null' % workdir) == 0
def test_context(): fn = context.get_fn('test/parameters_bks.txt') assert os.path.isfile(fn) fns = context.glob('test/parameters_*') assert fn in fns