Cargando…

chem(f): A purely functional chemistry toolkit

BACKGROUND: Although programming in a type-safe and referentially transparent style offers several advantages over working with mutable data structures and side effects, this style of programming has not seen much use in chemistry-related software. Since functional programming languages were designe...

Descripción completa

Detalles Bibliográficos
Autores principales: Höck, Stefan, Riedl, Rainer
Formato: Online Artículo Texto
Lenguaje:English
Publicado: BioMed Central 2012
Materias:
Acceso en línea:https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3660204/
https://www.ncbi.nlm.nih.gov/pubmed/23253942
http://dx.doi.org/10.1186/1758-2946-4-38
_version_ 1782270518125133824
author Höck, Stefan
Riedl, Rainer
author_facet Höck, Stefan
Riedl, Rainer
author_sort Höck, Stefan
collection PubMed
description BACKGROUND: Although programming in a type-safe and referentially transparent style offers several advantages over working with mutable data structures and side effects, this style of programming has not seen much use in chemistry-related software. Since functional programming languages were designed with referential transparency in mind, these languages offer a lot of support when writing immutable data structures and side-effects free code. We therefore started implementing our own toolkit based on the above programming paradigms in a modern, versatile programming language. RESULTS: We present our initial results with functional programming in chemistry by first describing an immutable data structure for molecular graphs together with a couple of simple algorithms to calculate basic molecular properties before writing a complete SMILES parser in accordance with the OpenSMILES specification. Along the way we show how to deal with input validation, error handling, bulk operations, and parallelization in a purely functional way. At the end we also analyze and improve our algorithms and data structures in terms of performance and compare it to existing toolkits both object-oriented and purely functional. All code was written in Scala, a modern multi-paradigm programming language with a strong support for functional programming and a highly sophisticated type system. CONCLUSIONS: We have successfully made the first important steps towards a purely functional chemistry toolkit. The data structures and algorithms presented in this article perform well while at the same time they can be safely used in parallelized applications, such as computer aided drug design experiments, without further adjustments. This stands in contrast to existing object-oriented toolkits where thread safety of data structures and algorithms is a deliberate design decision that can be hard to implement. Finally, the level of type-safety achieved by Scala highly increased the reliability of our code as well as the productivity of the programmers involved in this project.
format Online
Article
Text
id pubmed-3660204
institution National Center for Biotechnology Information
language English
publishDate 2012
publisher BioMed Central
record_format MEDLINE/PubMed
spelling pubmed-36602042013-05-23 chem(f): A purely functional chemistry toolkit Höck, Stefan Riedl, Rainer J Cheminform Methodology BACKGROUND: Although programming in a type-safe and referentially transparent style offers several advantages over working with mutable data structures and side effects, this style of programming has not seen much use in chemistry-related software. Since functional programming languages were designed with referential transparency in mind, these languages offer a lot of support when writing immutable data structures and side-effects free code. We therefore started implementing our own toolkit based on the above programming paradigms in a modern, versatile programming language. RESULTS: We present our initial results with functional programming in chemistry by first describing an immutable data structure for molecular graphs together with a couple of simple algorithms to calculate basic molecular properties before writing a complete SMILES parser in accordance with the OpenSMILES specification. Along the way we show how to deal with input validation, error handling, bulk operations, and parallelization in a purely functional way. At the end we also analyze and improve our algorithms and data structures in terms of performance and compare it to existing toolkits both object-oriented and purely functional. All code was written in Scala, a modern multi-paradigm programming language with a strong support for functional programming and a highly sophisticated type system. CONCLUSIONS: We have successfully made the first important steps towards a purely functional chemistry toolkit. The data structures and algorithms presented in this article perform well while at the same time they can be safely used in parallelized applications, such as computer aided drug design experiments, without further adjustments. This stands in contrast to existing object-oriented toolkits where thread safety of data structures and algorithms is a deliberate design decision that can be hard to implement. Finally, the level of type-safety achieved by Scala highly increased the reliability of our code as well as the productivity of the programmers involved in this project. BioMed Central 2012-12-20 /pmc/articles/PMC3660204/ /pubmed/23253942 http://dx.doi.org/10.1186/1758-2946-4-38 Text en Copyright © 2012 Höck and Riedl; licensee Chemistry Central Ltd. http://creativecommons.org/licenses/by/2.0 This is an Open Access article distributed under the terms of the Creative Commons Attribution License(http://creativecommons.org/licenses/by/2.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
spellingShingle Methodology
Höck, Stefan
Riedl, Rainer
chem(f): A purely functional chemistry toolkit
title chem(f): A purely functional chemistry toolkit
title_full chem(f): A purely functional chemistry toolkit
title_fullStr chem(f): A purely functional chemistry toolkit
title_full_unstemmed chem(f): A purely functional chemistry toolkit
title_short chem(f): A purely functional chemistry toolkit
title_sort chem(f): a purely functional chemistry toolkit
topic Methodology
url https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3660204/
https://www.ncbi.nlm.nih.gov/pubmed/23253942
http://dx.doi.org/10.1186/1758-2946-4-38
work_keys_str_mv AT hockstefan chemfapurelyfunctionalchemistrytoolkit
AT riedlrainer chemfapurelyfunctionalchemistrytoolkit