Ejemplo n.º 1
0
def call_proto_angle():
    '''
    Writes interim_f1_r-4-385.pdb
    cd test && ./$(BIN)_mtcon mtbig.pdb mtbig.pdb 209 1
    '''
    os.chdir('interim_coord')
    # print my_dir
    contact_dir = os.path.join(my_dir, 'contact_maps_new')
    interim_dir = os.path.join(my_dir, 'interim_coord')
    # sys.exit()

    if not os.path.exists(os.path.join(my_dir, 'contact_maps_new')):
        os.makedirs(os.path.join(my_dir, 'contact_maps_new'))

    lst_interim_coords = [
        'interim_f%d_r-%d-%d.pdb' % (i, resid_first, resid_last)
        for i in range(frame_first, frame_last + 1, step)
    ]
    for i, coord in enumerate(lst_interim_coords, frame_first):
        # print i
        os.chdir(contact_dir)
        cp_file(interim_dir, coord, contact_dir, coord)
        # print "check the call_run_new_contacts function for the correct reference coords"
        # run_command(['run_contacts_bond_vector_angle','pdbref.ent',coord]) # May 28th.
        run_command([
            'run_segment_mtcon',
            'pdbref.ent',
            coord,
        ])
        print coord
        os.remove(coord)
Ejemplo n.º 2
0
def call_mtcon():
    '''
    Writes interim_f1_r-4-385.pdb
    '''
    os.chdir('interim_coord')
    contact_dir = os.path.join(my_dir, 'contact_maps_new')
    interim_dir = os.path.join(my_dir, 'interim_coord')

    if not os.path.exists(os.path.join(my_dir, 'contact_maps_new')):
        os.makedirs(os.path.join(my_dir, 'contact_maps_new'))

    lst_interim_coords = [
        'interim_f%d_r-%d-%d.pdb' % (i, resid_first, resid_last)
        for i in range(frame_first, frame_last + 1, step)
    ]
    for i, coord in enumerate(lst_interim_coords, frame_first):
        # print i
        os.chdir(contact_dir)
        cp_file(interim_dir, coord, contact_dir, 'timelater.pdb')
        print coord
        run_command([
            'run_segment_mtcon', 'ref.pdb', 'timelater.pdb',
            str(num_chains),
            str(num_chains_i)
        ])
Ejemplo n.º 3
0
def call_run_new_contacts():
    '''
    Writes interim_f1_r-4-385.pdb
    '''
    os.chdir('interim_coord')
    # print my_dir
    contact_dir = os.path.join(my_dir, 'contact_maps_new')
    interim_dir = os.path.join(my_dir, 'interim_coord')
    # sys.exit()

    if not os.path.exists(os.path.join(my_dir, 'contact_maps_new')):
        os.makedirs(os.path.join(my_dir, 'contact_maps_new'))

    lst_interim_coords = [
        'interim_f%d_r-%d-%d.pdb' % (i, resid_first, resid_last)
        for i in range(frame_first, frame_last + 1, step)
    ]
    for i, coord in enumerate(lst_interim_coords, frame_first):
        # print i
        os.chdir(contact_dir)
        cp_file(interim_dir, coord, contact_dir, coord)
        print "check the call_run_new_contacts function for the correct reference coords"
        # run_command(['run_contacts_new','pdbref.ent',coord]) # MAY 28th.
        # run_command(['run_analyze','pdbref.ent',coord]) # August 8, 2015.
        run_command([
            'run_segment_contact', 'pdbref.ent', coord,
            str(num_chains),
            str(num_chains_i)
        ])
        print coord
        os.remove(coord)
Ejemplo n.º 4
0
    def run_hsa(self):

        os.chdir(self.coord_dir)

        fp_coords = glob.glob('interim_f*.rebuilt.pdb')

        # fp_ratios = []
        # for fp in fp_coords:
        #     print(fp)

        fp_ratios = [
            'Ratio_aa.%d.%d.%s' % (self.resid1, self.resid2, fp)
            for fp in fp_coords
        ]

        fp_targets = list(zip(fp_coords, fp_ratios))

        for fp in fp_targets:
            print(fp[0], fp[1])
            if not os.path.exists(fp[1]):
                print('run_area:')
                run_command(
                    ['run_area', fp[0],
                     str(self.resid1),
                     str(self.resid2)])
            else:
                print('%s:' % fp[1], 'exists, HSA complete.')
Ejemplo n.º 5
0
    def run_pulchra(self):

        try:
            print(self.coord_dir)
            if not os.path.exists(self.coord_dir):
                print("Could not locate: ", self.coord_dir)
                print("No coordinate directory.")
                return
        except AttributeError:
            print("No self.coord_dir")
            return

        os.chdir(self.coord_dir)
        # fp_coords = glob.glob(os.path.join(self.coord_dir,'interim_f*.pdb'))
        fp_coords = glob.glob('interim_f*.pdb')
        fp_interims = [f for f in fp_coords if not re.search('rebuilt', f)]
        fp_rebuilts = [re.sub('.pdb', '.rebuilt.pdb', f) for f in fp_interims]

        fp_tups = list(zip(fp_interims, fp_rebuilts))
        # print(fp_tups)

        # for i in range(len(fp_interims)):
        #     print(fp_interims[i])
        #     print(fp_rebuilts[i])
        #     print(fp_tups[i])

        # sys.exit()
        # print(fp_coords)
        # return

        for i in range(len(fp_tups)):
            if not os.path.exists(fp_tups[i][1]):
                run_command(['pulchra', fp_tups[i][0]])
            else:
                print('not running pulchra on:', fp_tups[i][0])
Ejemplo n.º 6
0
def compute_csu():
    print pdb
    # print psf
    # x = MoleculeUniverse(my_dir,psf,pdb,my_dir,option)
    # x.print_resids(resid_first,resid_last,1)
    for i in range(resid_first, resid_last + 1, 1):
        print i
        command_list = ["resc", pdb, str(i), "Y"]
        print '\n--------', command_list, '-----\n'
        run_command(command_list)
Ejemplo n.º 7
0
def call_pulchra():
    '''
    Writes interim_f1_r-4-385.pdb -> interim_f1_r-4-385.rebuilt.pdb if rebuilt has not been written.
    '''
    os.chdir('interim_coord')
    lst_interim_coords = [
        'interim_f%d_r-%d-%d.pdb' % (i, resid_first, resid_last)
        for i in range(frame_first, frame_last + 1, step)
    ]
    for coord in lst_interim_coords:
        rebuilt_coord = re.sub('pdb', 'rebuilt.pdb', coord)
        if not os.path.exists(rebuilt_coord):
            run_command(['pulchra', coord])
Ejemplo n.º 8
0
def call_run_area(code=0):
    if code == 0:
        lst_interim_coords = [
            'interim_f%d_r-%d-%d.rebuilt.pdb' % (i, resid_first, resid_last)
            for i in range(frame_first, frame_last + 1, step)
        ]
        for coord in lst_interim_coords:
            area_atom = 'Area_atom.' + coord
            area_aa = 'Area_aa.' + coord
            ratio_aa = 'Ratio_aa.' + coord
            if not os.path.exists(area_atom) or not os.path.exists(
                    area_aa) or not os.path.exists(ratio_aa):
                print 'run_area:', coord
                # run_command(['run_area',coord]) # run_area_orig
                # has the 4 385 (NBD) -> 1 382 effect 4-4+1, 385-4+1
                run_command([
                    'run_area', coord,
                    str(hresid_first - resid_first + 1),
                    str(hresid_last - resid_first + 1)
                ])
    else:
        # lst_interim_coords = ['interim_f%d_r-%d-%d.rebuilt.pdb' % (i,resid_first,resid_last) for i in range(frame_first,frame_last+1,step)]
        lst_interim_coords = [
            'interim_f%d_r-%d-%d.pdb' % (i, resid_first, resid_last)
            for i in range(frame_first, frame_last + 1, step)
        ]
        os.chdir('interim_coord')
        for coord in lst_interim_coords:
            # area_atom = 'Area_atom.' + coord
            # area_aa = 'Area_aa.' + coord
            # ratio_aa = 'Ratio_aa.' + coord
            # if not os.path.exists(area_atom) or not os.path.exists(area_aa) or not os.path.exists(ratio_aa):
            #     print 'run_area:',coord
            #     # run_command(['run_area',coord]) # run_area_orig
            #     # has the 4 385 (NBD) -> 1 382 effect 4-4+1, 385-4+1
            print 'run_area', coord, str(hresid_first - resid_first +
                                         1), str(hresid_last - resid_first + 1)
            run_command([
                'run_area', coord,
                str(hresid_first - resid_first + 1),
                str(hresid_last - resid_first + 1)
            ])
Ejemplo n.º 9
0
def call_run_contacts():
    '''
    Writes interim_f1_r-4-385.pdb
    '''
    os.chdir('interim_coord')

    if not os.path.exists(os.path.join(my_dir, 'contact_maps')):
        os.makedirs(os.path.join(my_dir, 'contact_maps'))

    lst_interim_coords = [
        'interim_f%d_r-%d-%d.pdb' % (i, resid_first, resid_last)
        for i in range(frame_first, frame_last + 1, step)
    ]
    for i, coord in enumerate(lst_interim_coords, frame_first):
        # print i
        # print os.getcwd()
        run_command([
            'run_contacts_calpha_res_count', coord,
            str(resid_last - resid_first + 1)
        ])
        # os.rename('Contact_map_residue_index_array.dat','Contact_map_residue_index_array_f%d.dat' % i)
        cp_file(os.getcwd(),'Contact_map_residue_index_array.dat',os.path.join(my_dir,'contact_maps'),\
                'Contact_map_residue_index_array_f%d.dat' % i)
Ejemplo n.º 10
0
# sys.exit()

# Run Analysis:
for k, v in dct_plot.iteritems():
    # print k,v['file']
    # print os.path.basename(v['dirname'])
    # ddir = ('/').join(os.path.split(v['dirname']))
    ddir = '/' + ('/').join(v['dirname'].split('/')[1:-1])

    if 1:
        print 'checking here:', ddir
        os.chdir(ddir)
        pdb = glob.glob('*.ref.pdb')[0]
        if not os.path.exists('pdbref.ent'):
            command1 = ['ln', '-s', pdb, 'pdbref.ent']
            run_command(command1)
        pdb = 'pdbref.ent'
        # dcd = glob.glob('dcd/*pull.dcd')[0]
        dcd = glob.glob('dcd/*.dcd')[0]

        # tops = glob.glob('*.top')[0]
        if re.search('AHM', ddir) != None:
            # ../../../../tops/MT_AHM.top
            # ../../../../tops/MT_PF56.top
            # ../../../../tops/MT_LHM.top
            # ../../../../tops/MT_regular.top
            command2 = [
                'ln', '-s', '../../../../tops/MT_AHM.top', 'top_this.top'
            ]
        elif re.search('LHM', ddir) != None:
            command2 = [
Ejemplo n.º 11
0
def run_chi_analysis(tup_resids):
    print 'running chi_analysis'

    fn_chi = 'chi_%s_frames_%d_%d_resids_%d_%d.dat' % (
        run_type, frame_first, frame_last, tup_resids[0], tup_resids[1])
    if os.path.exists(fn_chi):
        print fn_chi, 'exists!!'
        return

    # lst_interim_coords = glob('interim_coord/interim_*')
    # [lst_interim_coords.pop(i) for i,item in enumerate(lst_interim_coords) if re.search('rebuilt',item) != None]
    lst_interim_coords = [
        'interim_f%d_r-%d-%d.pdb' % (i, resid_first, resid_last)
        for i in range(frame_first, frame_last + 1, step)
    ]

    for path in lst_interim_coords:
        dir_coords = os.path.join(my_dir, 'interim_coord')
        fn_molecule = os.path.basename(path)
        # print path
        # print dir_coords
        # print fn_molecule
        result = re.search('\d+', fn_molecule)
        num = int(result.group(0))  # file_01.dat => 01

        # copy rebuit coord file into my_dir
        cp_file(dir_coords, fn_molecule, my_dir, fn_molecule)

        if run_type == 'sopnucleo':
            print 'need right molecule!?'
            # find the molecule
            sys.exit()
            command_list = ['run_chi',str(tup_resids[0]),str(tup_resids[1]), \
                            str(tup_resids[0]),str(tup_resids[1]),
                            'pdb%s4B9Q.pdb' % nucleotide,fn_molecule]

        elif run_type == 'gsop':
            if not os.path.exists(os.path.join(my_dir, '2kho_nbd.pdb')):
                cp_file(os.path.expanduser('~/sop_dev/tension'),
                        '2kho_nbd.pdb', my_dir, '2kho_nbd.pdb')
            command_list = ['run_chi',str(tup_resids[0]),str(tup_resids[1]), \
                            str(tup_resids[0]),str(tup_resids[1]),
                            '2kho_nbd.pdb',fn_molecule]

        elif run_type == 'sbd':
            # if not os.path.exists(os.path.join(my_dir,'2kho_sbd.pdb')):
            if not os.path.exists(os.path.join(my_dir, '2khosbd.pdb')):
                os.system(
                    'ln -s /home/dale/sop_dev/molecules/hsp70/pdb2khosbd_CA.ent 2khosbd.pdb'
                )
                # cp_file(os.path.expanduser('~/sop_dev/tension'),'2kho_sbd.pdb',my_dir,'2kho_sbd.pdb')
            command_list = ['run_chi',str(tup_resids[0]-382),str(tup_resids[1]-382), \
                            str(tup_resids[0]-382),str(tup_resids[1]-382),
                            '2khosbd.pdb',fn_molecule]
        # elif run_type == 'sbd':
        #     if not os.path.exists(os.path.join(my_dir,'2khosbd.pdb')):
        #         os.system('ln -s /home/dale/sop_dev/molecules/hsp70/pdb2khosbd_CA.ent 2khosbd.pdb')
        #         # cp_file(os.path.expanduser('~/sop_dev/molecules'),'2kho_sbd.pdb',my_dir,'2kho_sbd.pdb')
        #     command_list = ['run_tension',str(resid_first),str(resid_last),
        #                     '2khosbd.pdb',coord]

        # print command_list
        run_command(command_list)
        os.remove(os.path.join(my_dir, fn_molecule))

    print 'ran chi_analysis for %d to %d' % (tup_resids[0], tup_resids[1])

    # All Chi_residue files used in calculation but they get deleted in next for loop!
    # Chi_residue_117.dat*  Chi_residue_144.dat*  Chi_residue_18.dat*   Chi_residue_45.dat*
    lst_chi_files = glob(os.path.join(my_dir, 'Chi_residue*'))

    # extra dictionary before, going to list
    dct_chi_files = {}
    for path in lst_chi_files:
        fn_base = os.path.basename(path)
        print fn_base
        result = re.search('(?<=_)\d+', fn_base)
        num = int(result.group(0))
        print num, type(num)
        data = np.loadtxt(path)
        print data.shape

        # average computed
        avg_chi_value = np.mean(data)
        dct_chi_files[num] = {}
        dct_chi_files[num][
            'fn'] = fn_base  # extra, gets deleted ... 3 line later
        dct_chi_files[num]['fp'] = path
        dct_chi_files[num]['chi'] = avg_chi_value
        os.remove(path)

    # from dictionary to list ... averages compiled, saved
    lst_chi_avg = []
    for k, v in sorted(dct_chi_files.iteritems()):
        # print k,v['fp'],v['fn']
        print k, v['fn'], v['chi']
        lst_chi_avg.append(v['chi'])
    chi = np.array(lst_chi_avg)

    np.savetxt(fn_chi, chi, fmt='%0.6f')
Ejemplo n.º 12
0
def get_tension(fn_tension):
    # must clean out tension_output when you run tension
    os.chdir(my_dir)
    lst_tension_output = glob(os.path.join(my_dir, 'tension_output/*'))
    for path in lst_tension_output:
        # print path
        os.remove(path)
    # for path in os.listdir(os.path.join(my_dir,'tension_output')):
    #     print path
    #     # fp_path = os.path.join(my_dir,'tension_output',path)
    #     os.remove(fp_path)

    # sys.path.append('~/sop_dev/tension')
    # print sys.path
    # lst_interim_coords = glob('interim_coord/interim_*')
    # [lst_interim_coords.pop(i) for i,item in enumerate(lst_interim_coords) if re.search('rebuilt',item) != None]

    lst_interim_coords = [
        'interim_f%d_r-%d-%d.pdb' % (i, resid_first, resid_last)
        for i in range(frame_first, frame_last + 1, step)
    ]
    # print lst_interim_coords
    # sys.exit()
    # interim_f800_r-383-603.pdb

    for interim_coord in lst_interim_coords:
        # break
        dir_coord = os.path.join(my_dir, 'interim_coord')
        coord = os.path.basename(interim_coord)
        # print coord
        # print dir_coord
        cp_file(dir_coord, coord, my_dir, coord)
        # sys.exit()

        if run_type == 'sopnucleo':
            command_list = ['run_tension',str(resid_first),str(resid_last), \
                            'pdb%s4B9Q.pdb' % nucleotide,coord]

        elif run_type == 'gsop':
            command_list = ['run_tension',str(resid_first),str(resid_last), \
                            '2kho_nbd.pdb',coord]

        elif run_type == 'sbd':
            if not os.path.exists(os.path.join(my_dir, '2khosbd.pdb')):
                os.system(
                    'ln -s /home/dale/sop_dev/molecules/hsp70/pdb2khosbd_CA.ent 2khosbd.pdb'
                )
                # cp_file(os.path.expanduser('~/sop_dev/molecules'),'2kho_sbd.pdb',my_dir,'2kho_sbd.pdb')
            command_list = [
                'run_tension',
                str(resid_first),
                str(resid_last), '2khosbd.pdb', coord
            ]
            # command_list = ['run_tension',str(resid_first),str(resid_last),
            #                 '~/sop_dev/tension/2kho_sbd.pdb',coord]
            # 2kho_sbd.pdb

        print 'tension_command_list:', command_list
        # print os.getcwd()
        run_command(command_list)
        os.remove(coord)

    #  ---------------------------------------------------------  #
    #  get average!                                               #
    #  ---------------------------------------------------------  #
    dct_average = {}
    lst_tensions = glob(os.path.join(my_dir, 'tension_output/*.dat'))
    # print len(lst_tensions)
    # lst_tensions = ['tension_output/tension_%d.dat' % i for i in range(resid_first,resid_last)]
    # print len(lst_tensions)
    # sys.exit()
    if len(lst_tensions) == 0:
        print 'no tension files found!'
        sys.exit()
        # for path in sorted(glob(os.path.join(my_dir,'tension_output/*.dat'))):
    # print sorted(lst_tensions)
    time.sleep(3)
    for path in sorted(lst_tensions):
        # print path
        fn_base = os.path.basename(path)
        result = re.search('(?<=_)\d+', fn_base)
        num = result.group(0)
        data = np.loadtxt(path)
        force = data[::, 2]  # ARRAY SIZE,column
        force_avg = np.mean(force)
        dct_average[int(num)] = force_avg

    #  ---------------------------------------------------------  #
    #  savefile                                                   #
    #  ---------------------------------------------------------  #
    lst_average = []
    for k, v in sorted(dct_average.iteritems()):
        # print 'building list','\t --->',k,v
        lst_average.append(v)
        averages = np.array(lst_average)

    np.savetxt(fn_tension, averages, fmt='%2.4f')
Ejemplo n.º 13
0
def call_run_area(code=0):
    # lst_interim_coords = ['interim_f%d_r-%d-%d.pdb' % (i,resid_first,resid_last) for i in range(frame_first,frame_last+1,step)]
    # print os.getcwd().split('/')[-1]
    # sys.exit()
    if os.getcwd().split('/')[-1] != 'interim_coord':
        os.chdir('interim_coord')
    if code == 0:
        lst_interim_coords = [
            'interim_f%d_r-%d-%d.rebuilt.pdb' % (i, resid_first, resid_last)
            for i in range(frame_first, frame_last + 1, step)
        ]
        # lst_interim_coords = ['interim_f%d_r-%d-%d.rebuilt.pdb' % (i,resid_first,resid_last) for i in range(frame_first,frame_last+1,step)]
        # for coord in lst_interim_coords:
        #     area_atom = 'Area_atom.' + coord
        #     area_aa = 'Area_aa.' + coord
        #     ratio_aa = 'Ratio_aa.' + coord
        # if (not os.path.exists(area_atom) or not os.path.exists(area_aa) or not os.path.exists(ratio_aa)):
        #     print 'run_area:',coord
        #     # run_command(['run_area',coord]) # run_area_orig
        #     # has the 4 385 (NBD) -> 1 382 effect 4-4+1, 385-4+1
        #     run_command(['run_area',coord,str(hresid_first-resid_first+1),str(hresid_last-resid_first+1)])
    elif (code == 7 or code == 603):
        if code == 7:
            lst_interim_coords = [
                'interim_f%d_r-%d-%d.rebuilt.pdb' % (i, 1, 604)
                for i in range(frame_first, frame_last + 1, step)
            ]
        if code == 603:
            lst_interim_coords = [
                'interim_f%d_r-%d-%d.rebuilt.pdb' % (i, 383, 603)
                for i in range(frame_first, frame_last + 1, step)
            ]
        # for coord in lst_interim_coords:
        #     area_atom = 'Area_atom.' + coord
        #     area_aa = 'Area_aa.' + coord
        #     ratio_aa = 'Ratio_aa.' + coord
        # if not os.path.exists(area_atom) or not os.path.exists(area_aa) or not os.path.exists(ratio_aa):
        #     print 'run_area:',coord
        #     # run_command(['run_area',coord]) # run_area_orig
        #     # has the 4 385 (NBD) -> 1 382 effect 4-4+1, 385-4+1
        #     run_command(['run_area',coord,str(hresid_first-resid_first+1),str(hresid_last-resid_first+1)])
    else:
        # lst_interim_coords = ['interim_f%d_r-%d-%d.rebuilt.pdb' % (i,resid_first,resid_last) for i in range(frame_first,frame_last+1,step)]
        print 'trying to run on non-rebuilt structures??'
        sys.exit(1)
        # lst_interim_coords = ['interim_f%d_r-%d-%d.pdb' % (i,resid_first,resid_last) for i in range(frame_first,frame_last+1,step)]

        # for coord in lst_interim_coords:
        #     # area_atom = 'Area_atom.' + coord
        #     # area_aa = 'Area_aa.' + coord
        #     # ratio_aa = 'Ratio_aa.' + coord
        #     # if not os.path.exists(area_atom) or not os.path.exists(area_aa) or not os.path.exists(ratio_aa):
        #     #     print 'run_area:',coord
        #     #     # run_command(['run_area',coord]) # run_area_orig
        #     #     # has the 4 385 (NBD) -> 1 382 effect 4-4+1, 385-4+1
        #     print 'run_area',coord,str(hresid_first-resid_first+1),str(hresid_last-resid_first+1)
        #     run_command(['run_area',coord,str(hresid_first-resid_first+1),str(hresid_last-resid_first+1)])

    # final.
    for coord in lst_interim_coords:
        area_atom = 'Area_atom.' + coord
        area_aa = 'Area_aa.' + coord
        ratio_aa = 'Ratio_aa.1.%s.' % (str(resid_last - resid_first +
                                           1)) + coord
        #           Ratio_aa.1.65.interim_f8805_r-397-461.rebuilt.pdb
        print ratio_aa
        print resid_last, resid_last - resid_first
        # sys.exit()
        # if (not os.path.exists(area_atom) or not os.path.exists(area_aa) or not os.path.exists(ratio_aa)):
        if not os.path.exists(ratio_aa):
            print 'run_area:', coord
            # run_command(['run_area',coord]) # run_area_orig
            # has the 4 385 (NBD) -> 1 382 effect 4-4+1, 385-4+1
            run_command([
                'run_area', coord,
                str(hresid_first - resid_first + 1),
                str(hresid_last - resid_first + 1)
            ])
        else:
            print 'run_area:', coord, 'done previously.'
Ejemplo n.º 14
0
def call_pulchra(code=0):
    '''
    Writes interim_f1_r-4-385.pdb -> interim_f1_r-4-385.rebuilt.pdb if rebuilt has not been written.
    '''
    # print sys.args[::]
    print args
    # sys.exit()
    if os.getcwd().split('/')[-1] != 'interim_coord':
        os.chdir('interim_coord')
    if code == 7:
        lst_interim_coords = [
            'interim_f%d_r-%d-%d.pdb' % (i, 1, 604)
            for i in range(frame_first, frame_last + 1, step)
        ]
        # lst_interim_coords = ['interim_f%d_r-%d-%d.pdb' % (i,1,604) for i in range(frame_first,frame_last+1,step)]
    elif code == 603:
        lst_interim_coords = [
            'interim_f%d_r-%d-%d.pdb' % (i, 383, 603)
            for i in range(frame_first, frame_last + 1, step)
        ]
    elif code == 24:
        lst_interim_coords = [
            'interim_f%d_r-%d-%d.pdb' % (i, 389, 604)
            for i in range(frame_first, frame_last + 1, step)
        ]
    else:
        # print '<call_pulchra>',resid_first,resid_last
        print '<call_pulchra>', resid_first, resid_last
        lst_interim_coords = [
            'interim_f%d_r-%d-%d.pdb' % (i, resid_first, resid_last)
            for i in range(frame_first, frame_last + 1, step)
        ]
        # print lst_interim_coords

    # temp_coord_list = []
    # for i,coord in enumerate(lst_interim_coords):
    #     print coord
    #     temp_coord_file = re.sub('\.pdb','-temp.pdb',coord)
    #     print temp_coord_file
    #     if not os.path.exists(temp_coord_file):
    #         with open(temp_coord_file,'w+') as fw:
    #             with open(coord,'r+') as fp:
    #                 for line in fp.readlines():
    #                     if line.startswith('ATOM'):
    #                         fw.write(line)
    #             fw.write("END\n")
    #     # temp_coord_file = ['interim_f%d_r-%d-%d-temp.pdb']
    #     temp_coord_list.append(temp_coord_file)
    # # sys.exit()

    for i, coord in enumerate(lst_interim_coords):
        # for i,coord in enumerate(temp_coord_list):
        # rebuilt_coord = re.sub('-temp\.pdb','rebuilt.pdb',coord)
        rebuilt_coord = re.sub('pdb', 'rebuilt.pdb', coord)
        # print rebuilt_coord
        # print os.listdir(os.getcwd())
        # continue
        if not os.path.exists(rebuilt_coord):
            # os.remove(rebuilt_coord)
            # if 1:
            run_command(['which', 'pulchra'])
            print 'building with pulchra..', rebuilt_coord
            # print i,os.getcwd()
            run_command(['pulchra', '-v', coord])
        else:
            run_command(['which', 'pulchra'])
            print 'previously built:', rebuilt_coord
Ejemplo n.º 15
0
for i, fp in enumerate(lst_files):
    print('fp:', fp)
    fp_path = PurePath(fp)
    fp_base = fp_path.stem
    fp_gzip = fp_base + '.gz'
    # fp_zip = list(CWD.glob('./temp_file/**'))
    # fp_zip = glob('./temp_file/*')
    # temp_file = PurePath('temp_file',fp_gzip)

    print(fp_path)
    print(fp_base)
    # print('unzip:',fp_zip)
    print('gz:', fp_gzip)

    run_command(['unzip', '-d', 'temp_file', fp])

    temp_file = os.listdir('temp_file')[0]

    print('temp_file:', temp_file)

    run_command(['gzip', os.path.join('temp_file', temp_file)])

    # gzip_file = os.listdir('temp_file')[0]
    gzip_file = glob(os.path.join(os.getcwd(), 'temp_file/*'))[0]
    print(gzip_file)

    # break
    dest_file = os.path.join(os.getcwd(), 'nielsen_gzip', fp_gzip)

    # break