eugm 2014 - stefan höck (zurich university of applied sciences): cyby2: a modular rich client for...
DESCRIPTION
For successful medicinal chemistry projects, it is mandatory to have access to key correlations between chemical structures and their biological data such as potency, selectivity and pharmacological data to highlight and easily extrude structure activity relationships (SAR). A fully-fledged rich client application for the convenient storage and retrieval of chemical structures alongside the data of their biological activity in an underlying database that facilitates the structure-based data management and visualization of SAR will be presented. Being based on ChemAxon’s JChem and the Netbeans Platform the application is modular and thus easily expandable with additional functionality according to the individual user’s needs. With the functional programming paradigm finding its way more and more into mainstream programming languages, it was interesting from an academic point of view to write CyBy2 in purely functional style in a modern programming language (Scala). Our experiences with this programming paradigm especially when interacting with an object-oriented chemistry toolkit will also be addressed in the talk.TRANSCRIPT
![Page 1: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/1.jpg)
A modular Rich Client for managing
Chemical and Biological Data
![Page 2: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/2.jpg)
Who we are
Group of about 15 research scientists
Medicinal chemistry
Organic synthesis
Organic analysis
Cheminformatics
![Page 3: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/3.jpg)
Requirements
Chemical (structure-based) database
Client / Server architecture
Desktop application to access, search and
modify the database
Searching chemicals by (sub)structure
Flexible (modular) setup
![Page 4: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/4.jpg)
CyBy2-Server
JChem for storing / retrieving chemicals
Derby database
Akka middleware
![Page 5: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/5.jpg)
CyBy2-Client
Marvin Beans for drawing / displaying molecules
Modular design (based on Netbeans
platform)
![Page 6: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/6.jpg)
Features
Grouping compounds in projects
Linking of additional data (files) with
compounds
Linking of biological assay data with
compounds
Fine grained control over user access rights
![Page 7: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/7.jpg)
Main-View
![Page 8: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/8.jpg)
Grid-View
![Page 9: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/9.jpg)
Conditional Formatting
![Page 10: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/10.jpg)
CyBy2-Users
S.Höck, R.Riedl, Chimia 2012, 66, 132
![Page 11: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/11.jpg)
Programming
CyBy2 written completely in Scala
Multiparadigm (Object Oriented /
Functional)
CyBy2 written in purely functional style
![Page 12: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/12.jpg)
Functional Programming
Functions as first class values
Immutability
Type safe
Thread safe
Powerful abstractions
![Page 13: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/13.jpg)
Some code
•def atoms(m: Molecule): List[Atom] = ...
•def mass(a: Atom): Double = ...
•def mw(m: Molecule): Double =
• atoms(m).map(mass).sum
•Type inference + nicer syntax:
•def mw(m: Molecule) = atoms(m) map mass sum
![Page 14: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/14.jpg)
Error handling
•def mass(a: Atom): Option[Double] = ...
•Option: Type safe handling of undefined values:
•Some(12.011) if value is defined, otherwise None.
•No more NullPointerExceptions.
•But:
•def mw(m: Molecule) = atoms(m) map mass sum
•Compilation error: Can't sum over Option.
![Page 15: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/15.jpg)
Abstraction
•The Monoid Type Class
•trait Monoid[A] {
• def zero: A
• def add(a1: A, a2: A): A
•}
•Monoid instance for integer addition
•object IntMonoid extends Monoid[Int]{
• def zero: Int = 0
• def add(a1: Int, a2: Int): Int = a1 + a2
•}
![Page 16: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/16.jpg)
Data Accumulation
•Start with Monoid zero and accumulate through Monoid add:
•def accum[A](as: List[A])(M: Monoid[A]): A =
• as.foldLeft(M.zero)(M.add)
•Scala's type class mechanism lets us pass the Monoid instance implicitly:
•def accum[A](as: List[A])(implicit M: Monoid[A]): A =
• as.foldLeft(M.zero)(M.add)
![Page 17: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/17.jpg)
Data Accumulation
•class List[A] {
•
• def foldMap[B](f: A => B)(implicit M: Monoid[B]):B =
• foldLeft(M.zero)((b,a) => M.add(b, f(a)))
•
•}
•def mass(a: Atom): Double ...
•def mw(m: Molecule): Double = atoms(m) foldMap mass
![Page 18: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/18.jpg)
Error accumulation
•An Option of a Monoid automatically defines a Monoid:
•def mass(a: Atom): Option[Double] = ...
•def mw(m: Molecule) = atoms(m) foldMap mass
•Plus error handling (accumulating error messages for free):
•def mass(a: Atom): Validation[Double] = ...
•def mw(m: Molecule) = atoms(m) foldMap mass
![Page 19: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/19.jpg)
Molecular Formula
•type Formula = Map[Atom,Int]
•def singleAtom(a: Atom): Formula = Map(a -> 1)
•A Map with a Monoid as its value type defines another
Monoid:
•def formula(m: Molecule) = atoms(m) foldMap
singleAtom
![Page 20: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/20.jpg)
Functional Programming
Referentially transparent (immutability)
Thread safe
Powerful abstractions
Interoperability with non-functional libraries can
be awkward and unsafe
S.Höck, R.Riedl, J. Cheminform. 2012, 4, 38
![Page 21: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/21.jpg)
Thanks
![Page 22: EUGM 2014 - Stefan Höck (Zurich University of Applied Sciences): CyBy2: A modular Rich Client for the chemical and biological Information Management](https://reader035.vdocument.in/reader035/viewer/2022081401/559c46bc1a28ab7e218b470f/html5/thumbnails/22.jpg)
The End
•Questions ?