<commit_before><commit_msg>script to convert nc files to pdb <commit_after>#!/usr/bin/env python
from glob import glob
from subprocess import call, PIPE
import os
import argparse
from traj_utils import write_cpptraj_script

parser = argparse.ArgumentParser(prog='convert_to_pdb.py',
                                 formatter_class=argparse.RawDescriptionHelpFormatter,
                                 description='''version0.1''')

parser.add_argument("Trajectories", help="""A glob expression of .nc file trajectories""", type=str)
parser.add_argument("Topology", help="""The topology .prmtop file that matches
                    the trajectory""", type=str)


if __name__ == '__main__':
    args = parser.parse_args()
    traj_fns = glob(args.Trajectories)
    top_fn = args.Topology
    if not os.path.exists('pdbs'):
        os.makedirs('pdbs')
    for traj in traj_fns:
        print('Converting {}'.format(traj))
        with open('cmds.cpptraj', 'w') as f:
            f.write(write_cpptraj_script(traj, top_fn))
        call(['cpptraj', '-i', 'cmds.cpptraj'], stdout=PIPE)
        if os.path.exists('cmds.cpptraj'):
            os.remove('cmds.cpptraj')
{'fraction_non_alphanumeric': 0.1254295532646048, 'fraction_numerical': 0.001718213058419244, 'mean_word_length': 3.045138888888889, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '949225', 'n_tokens_mistral': 375, 'n_tokens_neox': 365, 'n_words': 82}