Package: complementaryc
Bioinformatics-101A friendly introduction to the Docker technologies. For more details about this technology, please visitthe official website.Pre-requisitesTo follow this guidelines please install in your local environmentDocker DesktopAbstractThis repository includes a dummy bioinformatics tool written in ANSI C language, called dna2rna, which transcripts an input string of DNA into a RNAm string:DNA sequence -> dna2rna -> RNAm sequenceThe source code is available insidemain.c:BEGIN
  1. Create a string called <RNA SEQ> with the same length as the input one <DNA SEQ>
  2. For each character <CURRENT> inside <DNA SEQ>:
  3.   Assign the matching value for <CURRENT> inside <OPPOSITE> // A <-> T, C <-> G
  4.   Put <OPPOSITE> inside <RNA_SEQ> at the same position that <CURRENT>
  5. Return <RNA SEQ>
ENDExamples:InputA-> OutputTInputaA-> OutputtTInputABCD-> OutputT?G?More information about the biological transcription process is availablehere.Compiling and runningThe first approach is cloning the repository and compiling it locally in order to build the executable file (object file)$gitclonegit@bitbucket.org:agdiaz/bioinformatics-101.git$cdbioinformatics-101$gcc-odna2rnamain.cAfterwards you will be able to execute the program:$./dna2rnaACGTTGCACreating a MakefileA logical next step seems to write aMakefileto automatize the compiling steps. It implies writing a rule to build the executable:build:gcc-odna2rnamain.cThis enables us to runmake buildto build the executable:$makebuildgcc -o dna2rna main.cDocker wayMain conceptsFrom the official documentation of Docker:ImagesAn image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization. For example, you may build an image which is based on the ubuntu image, but installs the Apache web server and your application, as well as the configuration details needed to make your application run.
You might create your own images or you might only use those created by others and published in a registry. To build your own image, you create a Dockerfile with a simple syntax for defining the steps needed to create the image and run it. Each instruction in a Dockerfile creates a layer in the image. When you change the Dockerfile and rebuild the image, only those layers which have changed are rebuilt. This is part of what makes images so lightweight, small, and fast, when compared to other virtualization technologies.ContainersA container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI. You can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state.
By default, a container is relatively well isolated from other containers and its host machine. You can control how isolated a container’s network, storage, or other underlying subsystems are from other containers or from the host machine.
A container is defined by its image as well as any configuration options you provide to it when you create or start it. When a container is removed, any changes to its state that are not stored in persistent storage disappear.Our dna2rna image and containerImageBuilding an image allow us to create instances of it later. The image is declared insideDockerfile. If you see this file, there are few lines describing how to create the image:FROM-> Basically we define our Docker image fromgcc:4.9WORKDIR-> We created a working folder inside the container (/src)COPY-> Copy ourmain.cfile inside theworking folderRUN-> Compile the code to generate the executable file inside usinggccENTRYPOINT-> Finally we declare the entry pointdna2rnawhich is the command to be executed after creating an instanceOnce you have theDockerfileit is easy to build the image:$dockerimagebuild.--tagdna2rnaDetails:docker image build: Build an image.: the path toDockerfile--tag dna2rnaa tag name to make easier using the image laterContainersWe can create instances from this image to execute the transcription program:$dockerrundna2rnaACGTacgtTGCAtgcaTGCAtgcaACGTacgtLet me explain you this command:We have created a Docker container from thedna2rnaimage previously builtThen, we sent theACGTacgtTGCAtgcaargument to the entry point defined in the last line of theDockerfileIf you want to be sure, please remove any executable file built before reaching this step and try it. You will see that it runs the code from inside the container!!!The advantages of the imagesOne of the most important benefits of building images is the possibility of publish them online to the community. For instance, I published this image to my personal repository on DockerHub (you may open yours) and now, anyone is able to create a container from that image and run the program without having to compile neither thinking about OS, dependencies, libraries, compilers.Let me show you how to run it directly from the published image:$dockerrundiazadriang/bioinformatics-101:latestACGTTGCAFinal thoughtsI strong recommend you to install Docker Desktop in your computer, start the program and run from your preferred terminal this dummy example.Any comment is welcomed here opening an issue or sending me an email toadrian.diaz@vub.be(ordiaz.adrian.g@gmail.com)Thanks for your time and happy coding!!!