예제 #1
0
def _prepare_pictures(sub):
    pictureslist = []
    picfile = None
    for key in sub.letter_annotations.keys():
        np = dict()
        np['picname'] = key
        np['secondary_structure'] = sub.letter_annotations[key]

        try:
            picfile = run_rnaplot(seq=str(sub.seq),
                                  structure=sub.letter_annotations[key],
                                  format='svg')
            with open(picfile) as f:
                np['pic'] = "data:image/svg+xml;utf8," + f.read()

            pictureslist.append(np)

            remove_one_file_with_try(picfile)
        except RNAplotException:
            print("can't draw structure with RNAfold for {}.".format(sub.id))
        except FileNotFoundError:
            if picfile is not None:
                print('cannot remove file: {}, file not found'.format(picfile))
        except OSError:
            if picfile is not None:
                print('cannot remove file: {}, file is directory'.format(
                    picfile))

    return pictureslist
예제 #2
0
 def test_plot_gml(self):
     run_rnaplot(self.seq, self.str, outfile=self.file, format="gml")
     self.assertTrue(loadfile_len(self.file))
예제 #3
0
 def test_basic(self):
     run_rnaplot(self.seq, self.str, outfile=self.file)
     self.assertTrue(loadfile_len(self.file))