Esempio n. 1
0
def build_plot_by_profile(filename, profile, oligo_id):
    rep_reads = {}
    fetchReads(filename, rep_reads, oligo_id)
    setFigType('png')
    fig = plotProfiles([profile], [rep_reads], [43], [False], ['Predicted'],
                       title='In Frame: %.1f%%' % rep_reads[FRAME_SHIFT])
    return fig
Esempio n. 2
0
def plot_predictions(theta_file, target_seq, pam_idx, out_filename=None):

    if pam_idx < 0 or pam_idx >= (len(target_seq) - 3):
        raise Exception('PAM idx out of range')

    if sum([x in ['A', 'T', 'G', 'C'] for x in target_seq]) != len(target_seq):
        raise Exception('Sequence must be composed of A,T,G,or C only')

    if len(target_seq) < 20 or pam_idx < 13 or pam_idx > len(target_seq) - 7:
        raise Exception(
            'Sequence too short or PAM too close to edge of sequence (must have at least 10nt either side of cut site)'
        )

    if target_seq[pam_idx + 1:pam_idx + 3] != 'GG':
        raise Exception('Non NGG PAM (check correct index of PAM)')

    profile, rep_reads, in_frame = predictMutations(theta_file, target_seq,
                                                    pam_idx)
    if not out_filename:
        out_filename = '%s_%d.txt' % (target_seq, pam_idx)
    fout = io.open(out_filename, 'w')
    fout.write(u'@@@%s\n' % ('%.1f' % in_frame))
    writePredictedProfileToSummary(profile, fout)
    fout.close()
    setFigType('png')
    fig = plotProfiles([profile], [rep_reads], [pam_idx], [False],
                       ['Predicted'],
                       title='In Frame: %.1f%%' % in_frame)
    return fig
Esempio n. 3
0
    compileGenIndelReads(gen_indel_dir=old_gen_dir,
                         out_dir=reads_dir,
                         sample_dirs=old_dirs)
    setReadsDir(reads_dir)

    #Compute features for each indel
    features_dir = getHighDataDir() + '/features_for_gen_indels'
    computeFeaturesForGenIndels(gen_indel_dir=new_gen_dir,
                                out_dir=features_dir)
    computeFeaturesForGenIndels(gen_indel_dir=old_gen_dir,
                                out_dir=features_dir)
    setFeaturesDir(features_dir)


if __name__ == '__main__':

    setIndelGenExe('/usr/local/bin/indelgen')
    setPlotDir('/results/plots')
    setFigType('png')

    shutil.copytree('/data/predicted_vs_measured_example',
                    '/results/predicted_vs_measured_example')
    prepareExample('/results/predicted_vs_measured_example')

    #Predict mutations using pre-trained model and compare to actual (for one oligo only)
    theta_file = getHighDataDir(
    ) + '/model_output_10000_0.01000000_0.01000000_-0.607_theta.txt_cf0.txt'
    computeAndComparePredicted(theta_file,
                               selected_id='Oligo35785',
                               out_dir='.')
Esempio n. 4
0
def build_plot_by_profile(filename, profile, oligo_id):
    rep_reads = {}
    fetchReads(filename, rep_reads, oligo_id)
    setFigType('png')
    fig = plotProfiles([profile], [rep_reads], [43], [False], ['Predicted'])
    return fig