Beispiel #1
0
    def test_logo_plot_noref(self):
        sc_des = {"sequence": "B"}

        # Start test
        df = ri.parse_rosetta_file(self.silent1, sc_des)

        fig, _ = rp.logo_plot(df, "B", refseq=False, line_break=50)
        plt.tight_layout()
        return fig
Beispiel #2
0
 def test_sse_logo(self):
     custom = {
         'E': '#0000FF', 'H': '#00FF00', 'L': '#FF0000'
     }
     ff = os.path.join(self.dirpath, 'input_3ssepred.minisilent.gz')
     df = ri.parse_rosetta_file(ff, {'structure': 'A'})
     fs = df.structure_bits('A')
     fig, axs = rp.logo_plot(fs, "A", refseq=False, line_break=50, font_size=10, hight_prop=2,
                             colors=custom)
     return fig
Beispiel #3
0
 def test_color_scheme_custom( self ):
     custom = {
         'A': '#e6194b', 'C': '#3cb44b', 'D': '#ffe119', 'E': '#ffe119',
         'F': '#f58231', 'G': '#911eb4', 'H': '#46f0f0', 'I': '#f032e6',
         'K': '#d2f53c', 'L': '#d2f53c', 'M': '#008080', 'N': '#e6beff',
         'P': '#aa6e28', 'Q': '#fffac8', 'R': '#800000', 'S': '#aaffc3',
         'T': '#808000', 'V': '#ffd8b1', 'W': '#000080', 'Y': '#808080'
     }
     df = rc.DesignFrame(pd.read_csv(os.path.join(self.dirpath, 'logo_plot_sequence.csv'),
                                     header=None).rename(columns={0: 'sequence_A'}))
     fig, axs = rp.logo_plot(df, "A", refseq=False, line_break=50, font_size=10, hight_prop=2,
                             colors=custom)
     return fig
Beispiel #4
0
    def test_logo_plot(self):
        refseq = "GSISDIRKDAEVRMDKAVEAFKNKLDKFKAAVRKVFPTEERIDMRPEIWIAQELRRIGDE" \
                 "FNAYRDANDKAAALGKDKEINWFDISQSLWDVQKLTDAAIKKIEAALADMEAWLTQ"

        sc_des = {"sequence": "B"}

        # Start test
        df = ri.parse_rosetta_file(self.silent1, sc_des)
        df.add_reference_sequence("B", refseq)

        fig, _ = rp.logo_plot(df, "B", refseq=True, line_break=50)
        plt.tight_layout()
        return fig
Beispiel #5
0
def main(options):
    if options.ifasta is None:
        infile = options.ifile if options.ifile is not None else options.ifiles
        defs = {"sequence": options.seqID}
        df = parse_rosetta_file(infile, defs, multi=options.ifiles is not None)
    else:
        df = read_fasta(options.ifasta)

    if options.ffile is not None:
        refseq = read_fasta(options.ffile).get_sequence("A").values[0]
        df.add_reference_sequence(options.seqID, refseq)

    # Alignment file
    alif = options.ofile + ".clw"
    write_clustalw(df, options.seqID, alif)

    # Mutation list file
    if options.ffile is not None:
        mutf = options.ofile + "_mutants.clw"
        write_mutant_alignments(df, options.seqID, mutf)

    # Logo Plot
    logof = options.ofile + "_logo" + "." + options.iformat
    lfig, _ = logo_plot(df,
                        options.seqID,
                        refseq=options.ffile is not None,
                        line_break=50,
                        font_size=int(options.ifont))
    plt.tight_layout()
    plt.savefig(logof)

    # Alignment plot
    afig = None
    if options.ffile is not None:
        alimgf = options.ofile + "_ali" + "." + options.iformat
        chunks = len(df.get_sequence(options.seqID).values[0])
        chunks = int(math.ceil(float(chunks) / 50))
        high_correct = math.ceil(df.shape[0] / 7.0)
        afig = plt.figure(figsize=(chunks * high_correct * 10, 10))
        grid = (chunks, 1)
        ax = []
        for i in range(chunks):
            ax.append(plt.subplot2grid(grid, (i, 0), fig=afig))
        plot_alignment(df, options.seqID, ax, line_break=50, matrix=None)
        plt.savefig(alimgf)

    return lfig, afig
Beispiel #6
0
 def test_color_scheme_charge( self ):
     df = rc.DesignFrame(pd.read_csv(os.path.join(self.dirpath, 'logo_plot_sequence.csv'),
                                     header=None).rename(columns={0: 'sequence_A'}))
     fig, axs = rp.logo_plot(df, "A", refseq=False, line_break=50, font_size=10, hight_prop=2,
                             colors="CHARGE")
     return fig
Beispiel #7
0
 def test_color_scheme_hydrophobicity( self ):
     df = rc.DesignFrame(pd.read_csv(os.path.join(self.dirpath, 'logo_plot_sequence.csv'),
                                     header=None).rename(columns={0: 'sequence_A'}))
     fig, axs = rp.logo_plot(df, "A", refseq=False, font_size=10, hight_prop=2,
                             colors='HYDROPHOBICITY')
     return fig