Skip to Content
Data Algorithms
book

Data Algorithms

by Mahmoud Parsian
July 2015
Intermediate to advanced
778 pages
17h 9m
English
O'Reilly Media, Inc.
Content preview from Data Algorithms

Chapter 24. DNA Base Count

This chapter provides four solutions for DNA base counting:

  • A MapReduce/Hadoop solution using FASTA format

  • A MapReduce/Hadoop solution using FASTQ format

  • A Spark solution using FASTA format

  • A Spark solution using FASTQ format

The purpose of this chapter is to count DNA1 bases. Human DNA’s code is written using only four letters—A, C, T, and G—and when we cannot recognize the code, we label it as N. The meaning of this DNA code lies in the sequence of the letters A, T, C, and G in the same way that the meaning of a word in the English language lies in the sequence of alphabet letters (A–Z).

In this chapter we’ll find the frequencies (or percentages) of A, T, C, G, and N in a given set of DNA sequences. We’ll also provide custom record readers for Hadoop’s input files.

So what do the letters ATCG stand for in the context of DNA? They refer to four of the nitrogenous bases associated with DNA:

  • A = Adenine

  • T = Thymine

  • C = Cytosine

  • G = Guanine

For example, ACGGGTACGAAT is a very small DNA sequence. DNA sequences can be huge.2 DNA base counting for our example will generate the results shown in Table 24-1.

Table 24-1. DNA base count example
Base Count
a 4
t 2
c 2
g 4
n 0

DNA sequences can be represented in many different formats, including the popular FASTA and FASTQ text-based formats, which are what we’ll use in our solutions. Note that Hadoop’s default record reader reads records line by line, and therefore we cannot ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Data Algorithms with Spark

Data Algorithms with Spark

Mahmoud Parsian
Grokking Algorithms

Grokking Algorithms

Aditya Bhargava
Graph Algorithms

Graph Algorithms

Mark Needham, Amy E. Hodler

Publisher Resources

ISBN: 9781491906170Errata Page