def construct(self): rng = np.random.RandomState(self.seed) moleculizer = partial( new_molecule, colors=lambda: rng.choice(MOLECULE_COLORS, size=3, replace=True)) proteins = molecule_universe_grid( moleculizer, num_molecules=(5, 8)).scale(0.3).center() proteins_frame = SurroundingRectangle(proteins, color=WHITE).round_corners(0.5) universe_title = Text('Known proteins').scale(0.7).next_to( proteins_frame, UP) framed_proteins = VGroup(universe_title, proteins_frame, proteins).to_edge(LEFT) self.play(FadeIn(framed_proteins)) self.wait(3) # --- Sequence -> Number -> MLM heavy, hcdr3 = hiv_antibody() heavy.next_to(framed_proteins, RIGHT) self.play(Transform(proteins[23], heavy)) self.wait(5) mlm = MLM().next_to(framed_proteins, RIGHT) self.play(ShrinkToCenter(heavy)) # , mlm.text self.wait(5) # FIXME: just to break here if mlm.text is not None: return # --- Subsets selected_proteins = [ proteins[i].copy() for i in rng.choice( len(proteins), replace=False, size=len(proteins) // 3) ] antibodies = VGroup( * [molecule_from_molecule(protein) for protein in selected_proteins]) antibodies_frame = (SurroundingRectangle(antibodies).match_color( proteins_frame).match_width(proteins_frame).match_height( proteins_frame)).round_corners(0.5) framed_antibodies = VGroup(antibodies_frame, antibodies) framed_antibodies.next_to(proteins, RIGHT, buff=MED_LARGE_BUFF) self.play( *[ ReplacementTransform(protein, antibody) for protein, antibody in zip(selected_proteins, antibodies) ], Write(antibodies_frame)) self.wait(4)
def __init__(self, target: Actor, label: str, direction: np.array): super().__init__(target) self.target = target self.label = "\n".join(wrap(label, 30)) self.direction = direction block = VGroup() title = Text(self.label, font="Helvetica").scale(0.7) rect = Rectangle(height=title.get_height() + 0.3, width=title.get_width() + 0.3) title.move_to(rect) block.add(rect, title) block.next_to(target.get_center(), direction) self.add(block)
def __init__(self, source: Actor, label: str): super().__init__(source) self.label = "\n".join(wrap(label, 30)) line_block = VGroup() spacing = 0.4 distance = 0.8 center_x = source.get_center()[0] line = Polygon( [center_x, spacing, 0], [center_x + distance, spacing, 0], [center_x + distance, -1 * spacing, 0], [center_x + distance / 2, -1 * spacing, 0], [center_x + distance, -1 * spacing, 0], [center_x + distance, spacing, 0], [center_x, spacing, 0], color=WHITE, ) line.set_stroke(width=ARROW_STROKE_WIDTH) arrow = Arrow( start=[center_x + distance, -1 * spacing, 0], end=[center_x, -1 * spacing, 0], buff=0, stroke_width=ARROW_STROKE_WIDTH, ) line_block.add(line, arrow) title = Text(self.label, font=self.source.font, size=0.5, slant=ITALIC) title.next_to(line_block) block = VGroup() block.add(line_block, title) block.next_to(source.get_center(), RIGHT) self.add(block)
def __init__(self, target: Actor, label: str): super().__init__(target) self.target = target self.label = "\n".join(wrap(label, 30)) line_block = VGroup() spacing = 0.4 distance = 0.8 line = Polygon( [target.get_center()[0], spacing, 0], [target.get_center()[0] + distance, spacing, 0], [target.get_center()[0] + distance, -1 * spacing, 0], [target.get_center()[0] + distance / 2, -1 * spacing, 0], [target.get_center()[0] + distance, -1 * spacing, 0], [target.get_center()[0] + distance, spacing, 0], [target.get_center()[0], spacing, 0], color=WHITE, ) line.set_stroke(width=ARROW_STROKE_WIDTH) arrow = Arrow( start=[target.get_center()[0] + distance, -1 * spacing, 0], end=[target.get_center()[0], -1 * spacing, 0], buff=0, stroke_width=ARROW_STROKE_WIDTH, ) line_block.add(line, arrow) title = Text(self.label, font="Helvetica", size=0.7, slant=ITALIC) title.next_to(line_block) block = VGroup() block.add(line_block, title) block.next_to(target.get_center(), RIGHT) self.add(block)
def construct(self): a_million_forks = Text('A million forks in the road to our products' ) # to drug development a_million_forks.to_edge(UP) new_drugs_per_billion_RD = [('1950', 100), ('1960', 50), ('1970', 10), ('1980', 5), ('1990', 3), ('2000', 2), ('2010', 1), ('2020', 1)] x = [x for x, _ in new_drugs_per_billion_RD] y = [y for _, y in new_drugs_per_billion_RD] colors = ["#003f5c", "#58508d", "#bc5090", "#ff6361", "#ffa600"] chart = BarChart( values=y, max_value=max(y), bar_colors=colors, bar_names=x, bar_label_scale_val=0.5, ).scale(0.8).to_edge(LEFT).shift(0.5 * DOWN) # text_top = ( # Text('EROOM\'s Law: More expensive, slower drug discovery') # .scale(0.9) # .next_to(chart, UP, buff=0.1) # ) # text_left = ( # Text('Number of drugs per billion US$ R&D spending') # .rotate(angle=TAU / 4, axis=OUT) # .scale(0.3) # .next_to(chart, LEFT, buff=0.5) # ) text_top = ( Text('Number of drugs per billion US$ R&D spending (log-scale)' ).scale(0.3).next_to(chart, UP, buff=0.5)) text_bottom = ( Text("Eroom's law: a continuous decline in Pharma R&D productivity" ).scale(0.3).next_to(chart, DOWN, buff=0.5)) # --- Examples of forks in the road icons_text = [ (SVGMobject(SVGS.ANTIBODY).set_color(BLUE).scale(0.8), Text('Is my antibody a potent, functional binder?')), (SVGMobject(SVGS.CYCLIC_PEPTIDE).set_color_by_gradient( BLUE, GREEN).scale(0.8), Text('Can we generate peptides without liabilities?')), (SVGMobject(SVGS.DNA).set_color_by_gradient(GREEN, BLUE).scale(0.8), Text( 'Can we optimize DNA to better express traits in plants or humans?' )), (SVGMobject(SVGS.PACMAN).set_color(RED).scale(0.8), Text('What will an enzyme in the human gut do?')), # ( # SVGMobject(SVGS.PACMAN).set_color_by_gradient(GREEN, BLUE, RED).scale(0.8), # Text('Can we optimize enzymes to better manufacture bioproducts?') # ), (SVGMobject(SVGS.PROTEIN3D).set_color_by_gradient( GREEN, BLUE, RED).scale(0.8), Text('What is the 3D structure of my biomolecule?')), (SVGMobject(SVGS.PATIENT).set_color_by_gradient(BLUE, RED).scale(0.8), Text('Will a patient respond to treatment in a clinical trial?')), (SVGMobject(SVGS.MUTATION).set_color_by_gradient(BLUE, GREEN, RED).scale(0.8), Text('...')) ] # icons_text = icons_text[:1] for (icon1, _), (icon2, _) in zip(icons_text, icons_text[1:]): icon2.next_to(icon1, DOWN, buff=0.5) for icon, text in icons_text: text.next_to(icon, RIGHT) questions = VGroup(*chain.from_iterable(icons_text)) questions.scale(0.32) questions.next_to(chart, RIGHT, buff=1).shift(0.5 * UP) logo = LoLLogo().scale(0.7) # logo.next_to(questions, DOWN, buff=0.5) logo.move_to(questions) # --- Animate self.play(FadeIn(text_top)) self.play(Write(chart), Write(text_bottom), run_time=4) self.wait(2) self.play(Write(a_million_forks)) for icon, text in icons_text: self.play(FadeIn(icon, text)) self.wait(3) # if we have put the logo under the questions... # self.play(FadeIn(logo)) # if we prefer the logo to morph from the questions actionable_insights = (Text( 'Getting actionable insights from biological sequences').next_to( logo, DOWN, buff=0.5).scale(0.4)) self.play(ReplacementTransform(questions, logo)) self.play(Write(actionable_insights)) self.wait(2)