@@ -0,0 +1,2035 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0A%0A%22%22%22Copy *.mol2 files to each folder, generate *_dock.in files.%22%22%22%0A%0Afrom __future__ import print_function%0A%0Aimport os%0Aimport re%0Afrom shutil import copyfile%0A%0Amol2_file_name = 'gan1.mol2'%0Aerror_list = %5B%5D%0A%0A%0Adef list_dirs():%0A    return %5Bname for name in os.listdir(%22.%22) if os.path.isdir(name)%5D%0A%0A%0Adef get_first_dock_in_file(dir_name):%0A    all_dock_in_files = %5Bname for name in os.listdir(dir_name)%0A                         if name.endswith(%22dock.in%22)%5D%0A    if not all_dock_in_files:%0A        error_list.append('--%3E NO dock.in file: %25s' %25 dir_name)%0A        return ''%0A    return all_dock_in_files%5B0%5D%0A%0A%0Adef modify_dock_in_file(dock_in_file_name, mol2_file_name):%0A    with open(dock_in_file_name, 'r') as f:%0A        lines = f.readlines()%0A    exists_name_re = re.compile(%22%5CS+.mol2%22)%0A    try:%0A        exists_name = exists_name_re.findall(lines%5B0%5D)%5B0%5D%0A    except:%0A        error_list.append(dock_in_file_name)%0A        return ''%0A    else:%0A        lines%5B0%5D = lines%5B0%5D.replace(exists_name, mol2_file_name)%0A        lines%5B1%5D = lines%5B1%5D.replace(exists_name.strip('.mol2'),%0A                                    mol2_file_name.strip('.mol2'))%0A        return ''.join(lines)%0A%0A%0Adef main():%0A    protern_dirs = list_dirs()%0A    for i, each_dir in enumerate(protern_dirs):%0A        one_dock_in_file = get_first_dock_in_file(each_dir)%0A        if not one_dock_in_file:%0A            print(%22%254d :  ERROR%22 %25 (i+1))%0A            continue%0A        print(%22%254d :  %25s  %7C  %25s%22 %25 (i+1, each_dir, one_dock_in_file))%0A        out_file = os.path.join(each_dir,%0A                                mol2_file_name.strip('.mol2')+'_dock.in')%0A        copyfile(mol2_file_name, os.path.join(each_dir, mol2_file_name))%0A        with open(out_file, 'w') as f:%0A            f.write(modify_dock_in_file(%0A                    os.path.join(each_dir,%0A                                 one_dock_in_file),%0A                    mol2_file_name))%0A    with open(%22error2016.txt%22, 'w') as f:%0A        f.write('%5Cn'.join(error_list))%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Add copy_files.py script