CodeDelphiPythonPython GUIRAD StudioWindows

Hands-On Bioinformatics With These 6 Powerful Python Libs

python delphi bioinformatics

Are you looking for tools to work in Bioinformatics and build a nice GUI for them?

You can build scalable Bioinformatics systems easily by combining these 6 powerful Python libraries and Python4Delphi for the GUI building part. Python4Delphi (P4D) is a free tool that allows you to execute Python scripts, create new Python modules and types in Delphi.

 What is Bioinformatics?

According to the National Human Genome Research Institute, Bioinformatics is a subdiscipline of biology and computer science concerned with the acquisition, storage, analysis, and dissemination of biological data, most often DNA and amino acid sequences. Bioinformatics uses computer programs for a variety of applications, including determining gene and protein functions, establishing evolutionary relationships, and predicting the three-dimensional shapes of proteins.

 Why use Python for Bioinformatics?

According to Bitesize Bio, Python is particularly well suited to researchers because several biology programmers have already contributed many libraries to make Python science-friendly. Python documentation also has a section dedicated to its scientific audience. Here are some more reasons why Python could be your best choice of programming language for biology research:

  • Widely used in the scientific community.
  • Well-built libraries for complex scientific problems.
  • Compatible with other existing tools.
  • Easy manipulation of sequences like DNA, RNA, amino acids.
  • Easy data manipulation and visualization.

Read these articles, to see “How Python is Powerful for Dealing with Scientific Purposes”:


Delphi adds Powerful GUI Features and Functionalities to Python

In this tutorial, we’ll build Windows Apps with extensive Bioinformatics capabilities by integrating Python’s Bioinformatics libraries with Embarcadero’s Delphi, using Python4Delphi (P4D).

P4D empowers Python users with Delphi’s award-winning VCL functionalities for Windows which enables us to build native Windows apps 5x faster. This integration enables us to create a modern GUI with Windows 10 looks and responsive controls for our Python for Bioinformatics applications. Python4Delphi also comes with an extensive range of demos, use cases, and tutorials.

We’re going to cover the following…

How to use Biopython, DEAP, Nilearn, PsychoPy, scikit-bio, and scikit-image Python libraries for Bioinformatics

All of them would be integrated with Python4Delphi to create Windows Apps with Bioinformatics capabilities.


Before we begin to work, download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out the easy instructions found in the Getting Started With Python4Delphi video by Jim McKeeth.


A practical demo app

First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.

Open Demo01.dproj
Open Demo01.dproj


1. How do you perform Bioinformatics tasks with Biopython?


The Biopython Project is an international association of developers of freely available Python tools for computational molecular biology.

What can I find in the Biopython package?

The main Biopython releases have lots of functionality, including:

  • The ability to parse bioinformatics files into Python utilizable data structures, including support for the following formats:
    • Blast output – both from standalone and WWW Blast
    • Clustalw
    • FASTA
    • GenBank
    • PubMed and Medline
    • ExPASy files, like Enzyme and Prosite
    • SCOP, including ‘dom’ and ‘lin’ files
    • UniGene
    • SwissProt
  • Files in the supported formats can be iterated over record by record or indexed and accessed via a Dictionary interface.
  • Code to deal with popular online bioinformatics destinations such as:
    • NCBI – Blast, Entrez, and PubMed services
    • ExPASy – Swiss-Prot and Prosite entries, as well as Prosite searches
  • Interfaces to common bioinformatics programs such as:
    • Standalone Blast from NCBI
    • Clustalw alignment program
    • EMBOSS command-line tools
  • A standard sequence class that deals with sequences, ids on sequences, and sequence features.
  • Tools for performing common operations on sequences, such as translation, transcription, and weight calculations.
  • Code to perform classification of data using k Nearest Neighbors, Naive Bayes, or Support Vector Machines.
  • Code for dealing with alignments, including a standard way to create and deal with substitution matrices.
  • Code making it easy to split up parallelizable tasks into separate processes.
  • GUI-based programs to do basic sequence manipulations, translations, BLASTing, etc.
  • Extensive documentation and help with using the modules, including this file, online wiki documentation, the website, and the mailing list.
  • Integration with BioSQL, a sequence database schema also supported by the BioPerl and BioJava projects.

After installing Python4Delphi properly, you can get Biopython using pip or easy install to your command prompt:

Don’t forget to put the path where your Biopython library installed, to the System Environment Variables:

System Environment Variable Examples

The following is a code example of the Biopython package to work with sequences and parsing FASTA formatted text file (run this inside the lower Memo of Python4Delphi Demo01 GUI):

Here is the final Biopython result in Python GUI

Biopython Demo with Python4Delphi in Windows.


2. How do you perform Bioinformatics tasks with DEAP?


DEAP is a novel evolutionary computation framework for the rapid prototyping and testing of ideas. It seeks to make algorithms explicit and data structures transparent. It works in perfect harmony with parallelization mechanisms such as multiprocessing and SCOOP.

DEAP includes the following features:

  • Genetic algorithm using any imaginable representation
    • List, Array, Set, Dictionary, Tree, Numpy Array, etc.
  • Genetic programing using prefix trees
    • Loosely typed, Strongly typed
    • Automatically defined functions
  • Evolution strategies (including CMA-ES)
  • Multi-objective optimization (NSGA-II, NSGA-III, SPEA2, MO-CMA-ES)
  • Coevolution (cooperative and competitive) of multiple populations
  • Parallelization of the evaluations (and more)
  • Hall of Fame of the best individuals that lived in the population
  • Checkpoints that take snapshots of a system regularly
  • Benchmarks module containing most common test functions
  • Genealogy of an evolution (that is compatible with NetworkX)
  • Examples of alternative algorithms: Particle Swarm Optimization, Differential Evolution, Estimation of Distribution Algorithm

How do I get the DEAP Python library?

First, here is how you can get DEAP:

The following code is the implementation of DEAP for One Max Problem. The code credited to these authors: Félix-Antoine Fortin, EunSeop Shin, and François-Michel De Rainville:

Here are the DEAP examples in the Python GUI:

DEAP Demo with Python4Delphi in Windows.


3. How do you perform Bioinformatics tasks with Nilearn?


Nilearn enables approachable and versatile analyses of brain volumes. It provides statistical and Machine Learning tools, with instructive documentation & a friendly community.

It supports general linear model (GLM) based analysis and leverages the scikit-learn Python toolbox for multivariate statistics with applications such as predictive modeling, classification, decoding, or connectivity analysis.

First, here is how you can get Nilearn:

Below is the code for fetching dataset using Nilearn (Run the following code inside the lower Memo of Python4Delphi Demo01 GUI):

here are the Nilearn Python4Delphi Results

Nilearn Demo with Python4Delphi in Windows.


4. How do you perform Bioinformatics tasks with PsychoPy?


PsychoPy is an open-source package for creating experiments in behavioral science. It aims to provide a single package that is:

  • precise enough for psychophysics
  • easy enough for teaching
  • flexible enough for everything else
  • able to run experiments in a local Python script or online in JavaScript

To meet these goals PsychoPy provides a choice of interface – you can use a simple graphical user interface called Builder or write your experiments in Python code. The entire application and library are written in Python and are platform-independent.

How to get the PsychoPy library?

First, here is how you can get PsychoPy:

Run these simple examples of PsychoPy code inside the lower Memo of Python4Delphi Demo01 GUI to generate your first stimulus:

PsychoPy Simple Examples:

PsychoPy Demo with Python4Delphi in Windows.


5. How do you perform Bioinformatics tasks with scikit-bio?


scikit-bio is an open-source, BSD-licensed python package providing data structures, algorithms and educational resources for bioinformatics.

Here is how you can install scikit-bio :

Run the following code to create a TabularMSA object with three DNA sequences and four positions:

Here is the scikit-bio Demo Result in the Python GUI:

scikit-bio Demo with Python4Delphi in Windows.


6. How do you perform Bioinformatics tasks with scikit-image?


scikit-image is an image processing library that implements algorithms and utilities for use in research, education, and industry applications. It is released under the liberal Modified BSD open source license, provides a well-documented API in the Python programming language, and is developed by an active, international team of collaborators.

scikit-image aims to:

  1. To provide high-quality, well-documented, and easy-to-use implementations of common image processing algorithms.
  2. To facilitate education in image processing.
  3. To address industry challenges.

First, here is how you can get scikit-image

Here is an example to interact with 3D images of kidney tissue:

scikit-image with Python4Delphi Results

scikit-image Demo with Python4Delphi in Windows.

The second output will show up in your default browser (just like the default Plotly output):

scikit-image Demo with Python4Delphi in Windows.


7. Are you ready to build awesome things with these Python’s Bioinformatics libraries?

We already demonstrate 6 powerful Python libraries for Bioinformatics (Biopython, DEAP, Nilearn, PsychoPy, scikit-bio, and scikit-image). All of them wrapped well inside a powerful GUI provided by Python4Delphi. We can’t wait to see what you build with Python4Delphi! 

Want to know some more? Then check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi, and

Download RAD Studio to build more powerful Python GUI Windows Apps 5x Faster with Less Code.

Related posts
DelphiDelphiVCLPythonPython GUIWindows

What is the MainForm Property in DelphiVCL.Application?

DelphiDelphiVCLPythonPython GUIWindows

Learn About The HelpJump Method For Displaying Help

DelphiDelphiVCLPythonPython GUIWindows

What Is The HookSynchronizeWakeup Method in DelphiVCL.Application?

DelphiDelphiVCLPythonPython GUIWindows

Learn About The Application's InitInstance Method

Leave a Reply

Your email address will not be published. Required fields are marked *