def test_stacked_columns():
        'It test the freq histogram'
        values = {
              'A': [0.66666666666666663, 0.33333333333333331, 0.0, 0.0, 0, 0.0],
              'C': [0.33333333333333331, 0.66666666666666663, 0.0, 0.0, 0, 0.0],
              'T': [0.0, 0.0, 1.0, 0.33333333333333331, 0, 1.0],
              'G': [0.0, 0.0, 0.0, 0.66666666666666663, 0, 0.0]}

        colors = {'A':'g', 'C':'b', 'T':'r', 'G':'k'}
        fhand = tempfile.NamedTemporaryFile(suffix='.svg')
        draw_stacked_columns(values, title='test', fhand=fhand, colors=colors)
        fhand.flush()
#        from franklin.utils.cmd_utils import call
#        call(('eog', fhand.name))
        svg = open(fhand.name, 'r').read()
        assert '<!-- Created with matplotlib (http://matplotlib' in svg
Ejemplo n.º 2
0
def create_nucleotide_freq_histogram(sequences, fhand=None, title=None, positions_to_study=30):
    """It writes a especific stacked_columns graphic representing the freq of
    each nucleotide per position"""
    values = _nucleotide_freq_per_position(sequences, positions_to_study=positions_to_study)

    # values should show starting with 1
    xvalues = range(len(values.values()[0]))
    xvalues.pop(0)
    xvalues.append(xvalues[-1] + 1)

    if not title:
        title = "Nucleotide frequency per position"
    colors = {"A": "g", "C": "b", "T": "r", "G": "k"}
    xlabel = "Sequence positions"
    ylabel = "Nucleotide frequency"

    draw_stacked_columns(values, colors, title=title, xlabel=xlabel, ylabel=ylabel, fhand=fhand, xvalues=xvalues)
    return values
Ejemplo n.º 3
0
def create_nucleotide_freq_histogram(sequences, fhand=None, title=None,
                                     positions_to_study=30):
    '''It writes a especific stacked_columns graphic representing the freq of
    each nucleotide per position'''
    values = _nucleotide_freq_per_position(sequences,
                                          positions_to_study=positions_to_study)

    #values should show starting with 1
    xvalues = range(len(values.values()[0]))
    xvalues.pop(0)
    xvalues.append(xvalues[-1] + 1)

    if not title:
        title = 'Nucleotide frequency per position'
    colors = {'A':'g', 'C':'b', 'T':'r', 'G':'k'}
    xlabel = 'Sequence positions'
    ylabel = 'Nucleotide frequency'

    draw_stacked_columns(values, colors, title=title, xlabel=xlabel,
                        ylabel=ylabel, fhand=fhand, xvalues=xvalues)
    return values