biological modeling, powered by angularjs

43
Biological Modeling, Powered by AngularJS Gil Fink CEO and Senior Consultant, sparXys @gilfink

Upload: gil-fink

Post on 11-Feb-2017

175 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Biological Modeling, Powered by AngularJS

Biological Modeling, Powered by

AngularJS

Gil Fink CEO and Senior Consultant, sparXys @gilfink

Page 2: Biological Modeling, Powered by AngularJS

This session is about working

with graphics

Page 3: Biological Modeling, Powered by AngularJS

But…

Page 4: Biological Modeling, Powered by AngularJS

I’m not a graphics designer

Page 5: Biological Modeling, Powered by AngularJS

This is how I draw toilets…

Page 6: Biological Modeling, Powered by AngularJS
Page 7: Biological Modeling, Powered by AngularJS

I wish…

Page 8: Biological Modeling, Powered by AngularJS
Page 9: Biological Modeling, Powered by AngularJS

And somebody let me speak

about graphics…

Page 10: Biological Modeling, Powered by AngularJS
Page 11: Biological Modeling, Powered by AngularJS

Ok, so let’s get serious!

Page 12: Biological Modeling, Powered by AngularJS

About Me • sparXys CEO and senior consultant

• Microsoft MVP

• Co-author of Pro Single Page Application

Development (Apress)

• Angular UP conference and GDG Rashlatz Meetup

co-organizer

Page 13: Biological Modeling, Powered by AngularJS

Agenda • SVG in a Nutshell

• SVG + AngularJS = <3

• Use Case: Biological Modeling

Page 14: Biological Modeling, Powered by AngularJS

SVG in a Nutshell • Graphics model in the browser

• Create and draw 2D vector graphics using HTML

• Support for: o Full DOM access

o Document structure, scripting, styling, paths, shapes, colors, transforms,

gradients, patterns, masking, clipping, markers, linking and views

Page 15: Biological Modeling, Powered by AngularJS

2D Vector Graphics

<svg width="400" height="200" xmlns="http://www.w3.org/2000/svg"> <rect fill="red" x="20" y="20" width="100" height="75" /> <rect fill="blue" x="50" y="50" width="100" height="75" /> </svg>

Page 16: Biological Modeling, Powered by AngularJS

What we can do with SVG? Demo

http://www.themaninblue.com/experiment/Blobular/

http://lavadip.com/experiments/jigsaw/

Page 17: Biological Modeling, Powered by AngularJS

SVG + AngularJS = <3

Combining SVG and AngularJS isn’t hard

SVG elements are part of the DOM!

Page 18: Biological Modeling, Powered by AngularJS

SVG + AngularJS 1 Caveats • In directives that generate SVG, use

templateNamespace in the DDO:

• Set SVG attributes using ng-attr- prefix:

<circle ng-attr-cx="{{radius}}" ng-attr-cy="{{radius}}" ng-attr-r="{{radius}}"/>

templateNamespace: 'svg'

Page 19: Biological Modeling, Powered by AngularJS

SVG & AngularJS 1 Directive Demo

Page 20: Biological Modeling, Powered by AngularJS

SVG + Angular 2 Caveats • In components that generate SVG, use svg: prefix

when using SVG elements:

• Set SVG attributes using attr. prefix:

• Remember:

SVG cannot accept elements it doesn't recognize! o Don’t create your own named components, use named attributes instead

<svg:circle [attr.cx]="radius" [attr.cy]="radius" [attr.r]="radius"/>

<svg:circle cx="10" cy="10" r="30"/>

Page 21: Biological Modeling, Powered by AngularJS

SVG + Angular 2 Component Demo

Page 22: Biological Modeling, Powered by AngularJS

Use Case Using SVG + AngularJS for Biological Modeling

Page 23: Biological Modeling, Powered by AngularJS

Biology Disclaimer

Page 24: Biological Modeling, Powered by AngularJS

Biology 101 • Plasmids - small DNA molecules represented as a

circle with annotations

Page 25: Biological Modeling, Powered by AngularJS

Biology 101 • Sequence – primary structure of a biological

molecule written in characters (A, T, G, C)

Page 26: Biological Modeling, Powered by AngularJS

Customer Needs • Synchronize plasmid and sequence views

• Fast scrolling

• Sequence and plasmid selection

• Annotation layers

Page 27: Biological Modeling, Powered by AngularJS

Lazy Developer

Page 28: Biological Modeling, Powered by AngularJS

Are there any JavaScript

libraries for plasmids or

sequences? Preferable with AngularJS support?

Page 29: Biological Modeling, Powered by AngularJS

Maybe in BioJS? http://www.biojs.io/

Page 30: Biological Modeling, Powered by AngularJS

AngularPlasmid • DNA plasmid visualization component using

AngularJS and SVG

• http://angularplasmid.vixis.com/index.php

<plasmid sequencelength='1000'> <plasmidtrack radius='50'> <tracklabel text='Demo'></tracklabel> <trackscale interval='100' showlabels='1'></trackscale> <trackmarker start='212' end='345'></trackmarker> <trackmarker start='530' end='650'> <markerlabel text='Ecol'></markerlabel> </trackmarker> <trackmarker start='677' end='820'></trackmarker> </plasmidtrack> </plasmid>

Page 31: Biological Modeling, Powered by AngularJS

Problems We Faced • Generating the plasmid dynamically from specific

files o Solved by dynamically adding AngularPlasmid elements

o Then, we use the $compile service

• Adding selection to the plasmid o Solved by adding our own implementation

Page 32: Biological Modeling, Powered by AngularJS

Demo AngularPlasmid + $compile

Page 33: Biological Modeling, Powered by AngularJS

No DNA sequence library

Page 34: Biological Modeling, Powered by AngularJS

Building the Sequence – The Naïve Way

• Let AngularJS generate the whole sequence o Use ng-repeat, SVG and browser scrolling

• Add annotation layers with SVG

• The problem is…

Page 35: Biological Modeling, Powered by AngularJS
Page 36: Biological Modeling, Powered by AngularJS

What’s the problem?

Page 37: Biological Modeling, Powered by AngularJS
Page 38: Biological Modeling, Powered by AngularJS

Can we do better? Maybe infinite scrolling?

Not good enough!

Page 39: Biological Modeling, Powered by AngularJS

Virtual Scrolling • Generate only the current viewport

• Good reading reference: o https://developers.google.com/web/updates/2016/07/infinite-scroller?hl=en

o http://blog.stackfull.com/2013/02/angularjs-virtual-scrolling-part-1/

o http://blog.stackfull.com/2013/03/angularjs-virtual-scrolling-part-2/

Page 40: Biological Modeling, Powered by AngularJS

Front-end Architecture

AngularPlasmid

Each row is a directive

Page 41: Biological Modeling, Powered by AngularJS

Demo Genome Viewer

Page 42: Biological Modeling, Powered by AngularJS

Summary • SVG is one of the options to create graphics in

the browser

• SVG and AngularJS can work well together

• You can create sophisticated modeling using SVG and AngularJS

Page 43: Biological Modeling, Powered by AngularJS

Thank You!