예제 #1
0
def plot_all_fits(filename, use_agg=False, ylims=(-1, -1)):
    """Plot fitness function vs. iteration for each pair at each state

    Args
    ----
    filename : str
        Name of file from which to read.
    use_agg : bool
        Use Agg backend if True - may be useful on clusters with no display
    ylims : iterable, len=2
        Set the ylimits of the f_fit axes - useful for comparing plots of different pairs

    Returns
    -------
    Nothing is returned, but plots are made for each pair.

    If the directory './figures' does not exist, it is created, and the figures 
    are saved in that directory with the name 'type1-type2-fit.pdf'.
    The filename should where the optimization output was redirected, as the 
    format is determined by the MSIBI.optimize() function.
    """
    fits = parse_logfile(filename)
    if not os.path.exists('figures'):
        os.makedirs('figures')
    for pair in fits:
        plot_pair_fits(pair, fits, use_agg, ylims)
예제 #2
0
def plot_all_fits(filename, use_agg=False, ylims=(-1, -1)):
    """Plot fitness function vs. iteration for each pair at each state

    Args
    ----
    filename : str
        Name of file from which to read.
    use_agg : bool
        Use Agg backend if True - may be useful on clusters with no display
    ylims : iterable, len=2
        Set the ylimits of the f_fit axes - useful for comparing plots of different pairs

    Returns
    -------
    Nothing is returned, but plots are made for each pair.

    If the directory './figures' does not exist, it is created, and the figures 
    are saved in that directory with the name 'type1-type2-fit.pdf'.
    The filename should where the optimization output was redirected, as the 
    format is determined by the MSIBI.optimize() function.
    """
    fits = parse_logfile(filename)
    if not os.path.exists('figures'):
        os.makedirs('figures')
    for pair in fits:
        plot_pair_fits(pair, fits, use_agg, ylims)
예제 #3
0
def test_all_pairs_same_number_of_states():
    filename = get_fn('opt.out')
    logfile_info = parse_logfile(filename)
    assert (len(logfile_info) == 15)
    for pair, states in logfile_info.items():
        assert len(states) == 4
        for state, f_fits in states.items():
            assert (len(f_fits) == 8)
예제 #4
0
def test_all_pairs_same_number_of_states():
    filename = get_fn('opt.out')
    logfile_info = parse_logfile(filename)
    assert(len(logfile_info) == 15)
    for pair, states in logfile_info.items():
        assert len(states) == 4
        for state, f_fits in states.items():
            assert(len(f_fits) == 8)
예제 #5
0
def plot_all_rdfs(logfile_name,
                  target_dir,
                  potentials_dir='./potentials',
                  rdf_dir='./rdfs',
                  step=-1,
                  use_agg=False,
                  to_angstrom=1.0,
                  to_kcalpermol=1,
                  lw=None):
    """Plot the RDF vs. the target for each pair at each state

    Args
    ----
    fits : dict
        Dict with {pairs: {states: fits}}, as returned from parse_logfile
    target-dir : str
        path (relative or absolute) to target RDFs
    potentials_dir : str
        path (relative or absolute) to potentials from optimization
    step : int
        Print RDFs and potentials from this step
    use_agg : bool
        True to use Agg backend, may be useful on clusters with no display

    Returns
    -------
    Nothing is returned, but figures are plotted in './figures'

    The target rdfs are expected to have the format 'target-dir/type1-type2-state.txt'
    """
    if not os.path.exists('figures'):
        os.makedirs('figures')
    logfile_info = parse_logfile(logfile_name)
    for pair, state in logfile_info.items():
        for state, fits in state.items():
            if step == -1:
                step = len(fits) - 1
            type1 = pair.split('-')[0]
            type2 = pair.split('-')[1]
            plot_pair_at_state(type1,
                               type2,
                               state,
                               step,
                               target_dir,
                               potentials_dir,
                               rdf_dir,
                               use_agg,
                               to_angstrom,
                               to_kcalpermol,
                               lw=lw)
예제 #6
0
def animate_all_pairs_states(logfile_name, target_dir, 
        potentials_dir='./potentials', rdf_dir = './rdfs', step=-1, 
        use_agg=False, to_angstrom=6.0, to_kcalpermol=0.1, n_skip=1):
    """Plot the RDF vs. the target for each pair at each state

    Args
    ----
    fits : dict
        Dict with {pairs: {states: fits}}, as returned from parse_logfile
    target-dir : str
        path (relative or absolute) to target RDFs
    potentials_dir : str
        path (relative or absolute) to potentials from optimization
    step : int
        Print RDFs and potentials from this step
    use_agg : bool
        True to use Agg backend, may be useful on clusters with no display
    n_skip : int
        Set ylimits on RDF plot with RDFs after n_skip

    Returns
    -------
    Nothing is returned, but figures are plotted in './animations'

    The target rdfs are expected to have the format 'target-dir/type1-type2-state.txt'
    """
    if not os.path.exists('animations'):
        os.makedirs('animations')
    logfile_info = parse_logfile(logfile_name)
    for pair, state in logfile_info.items():
        for state, fits in state.items():
            if step == -1:
                step = len(fits)
            type1 = pair.split('-')[0]
            type2 = pair.split('-')[1]
            animate_pair_at_state(type1, type2, state, step, target_dir,
                    potentials_dir, rdf_dir, use_agg, to_angstrom, 
                    to_kcalpermol, n_skip)
예제 #7
0
from msibi_utils.plot_fit import plot_all_fits
from msibi_utils.animate_rdf import animate_all_pairs_states
from msibi_utils.parse_logfile import parse_logfile
from msibi_utils.find_best_iterations import find_best_iterations

logfile = 'charmm_bi/6-12-18.log'
log_info = parse_logfile(logfile)
best_iterations = find_best_iterations(logfile)
print(best_iterations)
plot_all_fits(logfile, use_agg=True, ylims=(0, 1))
animate_all_pairs_states(
    logfile,
    "charmm_bi/rdfs",
    potentials_dir="charmm_bi/potentials",
    rdf_dir="charmm_bi/rdfs",
    potentials2_dir="charmm_bulk_debi_flhe_dspc/potentials",
    rdf2_dir="charmm_bulk_debi_flhe_dspc/rdfs",
    use_agg=True)