コード例 #1
0
    yml_path = Path('manual_alignments.yml')
    with yml_path.open() as file:
        manual_alignments = yaml.load(file)

    for hit in hits:
        real_seq = sgrna_sensor.from_name(hit).rna
        aligned_seq = ''.join(
                x for x in manual_alignments[hit]
                if x in 'ACGU'
        )
        if real_seq != aligned_seq:
            raise ValueError(f"""\
The manual alignment for {hit} has the wrong sequence!

> {real_seq}
> {aligned_seq}""")

    return manual_alignments

if __name__ == '__main__':
    args = docopt.docopt(__doc__)

    fold_changes = calc_fold_changes(args['--force'])
    fold_change_strs = {
            k: fr"{v[0]:.1f}\textsuperscript{{{'−+'[v[1]]}}}"
            for k,v in fold_changes.items()
    }
    manual_alignments = load_manual_alignments()
    ligands = {k: sgrna_sensor.from_name(k).ligand or 'theo' for k in hits}
    sgrna_sensor.render_latex_table('library_hits.tex', locals())
コード例 #2
0
#!/usr/bin/env python3

"""\
Make a table of the randomly generated spacer sequences.

Usage:
    tabulate_doench_spacers.py
"""

from os.path import join, dirname
from sgrna_sensor import render_latex_table
from pprint import pprint

fields = []
context = {'fields': fields}
doench_tsv = join(dirname(__file__), 'doench_spacers.tsv')

with open(doench_tsv) as file:
    for line in file:
        d_id, seq, score = line.split()
        id = int(d_id.strip('d'))
        row = 1 + (id - 1) // 8
        col = 1 + (id - 1) % 8
        seq = seq[0:4].lower() + seq[4:24].upper() + seq[24:30].lower()
        score = float(score)

        if id <= 24:
            fields.append((id, row, col, seq, score))

render_latex_table('doench_spacers.tex', context)
コード例 #3
0
        return 'Upper Stem'
    if name[1] == 'x':
        return 'Nexus'
    if name[1] == 'h':
        return 'Hairpin'

    raise ValueError(f"can't determine domain for {name}")


if __name__ == '__main__':
    args = docopt.docopt(__doc__)
    df = tabulate_sequences()

    # Initialize the manual alignment file.
    if args['reset_alignment']:
        if alignment_path.exists() and not args['--force']:
            print(f"{alignment_path} already exists, pass -f to overwrite.")
            raise SystemExit

        print(df)
        sequences = {
                row['name']: row['sequence']
                for i, row in df.iterrows()
        }
        with alignment_path.open('w') as file:
            yaml.dump(sequences, file)

    # Make the table.
    else:
        sgrna_sensor.render_latex_table('library_sequences.tex', locals())
コード例 #4
0
    return names[x]


args = docopt.docopt(__doc__)

# Parse the densiometry data.
df = densiometry.load_cleavage_data_from_xlsx_dir(DATA_DIR)
df = densiometry.calc_mean_change(df)

# Add NaNs for the experiments that didn't work.
df = df.append({'spacer': 'd9', 'design': 'on'}, ignore_index=True)

# Add a column for the names I want to display.
df = df[df.design.isin(DESIGN_ORDER)]
df['construct'] = df.design.apply(get_construct)

# Put the rows in the order I want to display them in.
spacer_order = densiometry.sort_spacers_by_activity(df, ['mhf 30', 'rxb 11,1'])
df['spacer'] = pd.Categorical(df.spacer, spacer_order)
df['design'] = pd.Categorical(df.design, DESIGN_ORDER)
df = df.sort_values(['spacer', 'design']).reset_index()

n = len(df) // 2
context = { #
        'df': df,
        'spacers': parse_spacers(spacer_order),
        'isnull': pd.isnull,
}

render_latex_table('raw_data.tex', context)
コード例 #5
0
        ('folA spacer', spacer('fol1')),
        ('Theophylline (theo) aptamer', aptamer('theo')),
        ('3-Methylxanthine (3mx) aptamer', aptamer('3mx')),
        ('Thiamine pyrophosphate (tpp) aptamer', aptamer('tpp')),
        ('Positive control', from_name('on')),
        (r'Negative control (G63C, G64C)', from_name('off')),
        (r'\ligrnaF{}', from_name('mhf/30')),
        (r'\ligrnaF[2]{}', from_name('mhf/37')),
        (r'\ligrnaF[3]{}', from_name('w30/65')),
        (r'\ligrnaF[4]{}', from_name('w30/64/1')),
        (r'\ligrnaB{}', from_name('rxb/11/1')),
        (r'\ligrnaB[2]{}', from_name('w11/2')),
        (r'\ligrnaB[3]{}', from_name('m11/ga')),
]

with open('manual_alignments.yml') as file:
    manual_alignments = yaml.load(file)

# Make sure there aren't any typos.
for name, sgrna in components:
    if name in manual_alignments:
        aligned_seq = ''.join(x for x in manual_alignments[name] if x in 'ATCG')
        assert sgrna.dna.upper() == aligned_seq.upper(), f"""\
Name:     {name}
Expected: {sgrna.dna.upper()}
Actual:   {aligned_seq.upper()}
"""

render_latex_table('components.tex', locals())