def run_pymol_script(pml, width=500, height=500): is_quit = 'quit' in util.words_in_file(pml) if is_quit: pymol_batch = data.binary("pymol_batch") cmd = pymol_batch + ' -c ' else: pymol = data.binary("pymol") cmd = pymol + " -q " # no splash screen cmd += " -W %d -H %d " % (width, height) cmd += pml util.run_with_output(cmd)
def convert_crd_to_trj_frame(crd): vals = [float(word) for word in util.words_in_file(crd)[1:]] lines = [] line = '' for i in range(0, len(vals)): line += "%8.3f" % vals[i] if (i % 10) == 9: lines.append(line) line = '' if line: lines.append(line) return '\n'.join(lines) + '\n'
def convert_crd_to_trj_frame(crd): """ Returns a string that corresponds to a frame in a .trj from a .crd file. This is for writing to .trj files. """ vals = [float(word) for word in util.words_in_file(crd)[1:]] lines = [] line = '' for i in range(0, len(vals)): line += "%8.3f" % vals[i] if (i % 10) == 9: lines.append(line) line = '' if line: lines.append(line) return '\n'.join(lines) + '\n'
def expand_pdbs(*pdbs): """ Returns a cleaned-up list of PDB codes given a mixed list of pdb codes, pdb filenames, and text files containing such. """ results = [] for pdb in pdbs: if os.path.isfile(pdb): print "Reading PDB codes from", pdb new_pdbs = expand_pdbs(*util.words_in_file(pdb)) results.extend(new_pdbs) else: pdb = pdb.lower() if pdb.endswith('.pdb'): pdb = pdb[:-4] if len(pdb) != 4: raise Exception("PDB code is not 4 letters long") results.append(pdb) return results