<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Genetics - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Genetics - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sat, 30 May 2026 22:26:17 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/genetics/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ The Novel Coronavirus Epidemic in China: How to Help Researchers Using Sequence Alignment on 2019-nCoV with MAFFT ]]>
                </title>
                <description>
                    <![CDATA[ By Shen Huang Novel Coronavirus (2019-nCoV) is a deadly virus that seems to have originated in Wuhan, China. As of January 26, the virus has already caused 76 deaths. As a coronavirus targeting human respiratory systems, 2019-nCoV is highly infectiou... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/china-novel-coronavirus-epidemic-sequence-alignment-2019-ncov-mafft/</link>
                <guid isPermaLink="false">66d460f03a8352b6c5a2aafd</guid>
                
                    <category>
                        <![CDATA[ mafft ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Genetics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 27 Jan 2020 11:04:41 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/01/image-64-1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Shen Huang</p>
<p>Novel Coronavirus (2019-nCoV) is a deadly virus that seems to have originated in Wuhan, China. As of January 26, the virus has already caused 76 deaths.</p>
<p>As a coronavirus targeting human respiratory systems, 2019-nCoV is highly infectious – especially during wet and cold seasons.</p>
<p>When people sneeze, they can shoot out respiratory system-related pathogens at a high speed. These can infect humans in many ways – most often through contacting mouth, nose, and eyes.</p>
<p>To avoid infections, you should avoid outdoor activities – especially in crowded areas. It's also important to sanitize your hands often and not to rub your eyes with your hands.</p>
<p>I'm in China, and my plans for Lunar New Year are now ruined. So I decided to stay home and create this tutorial on how to obtain genetic sequence data of 2019-nCoV and perform a Sequence Alignment on it with MAFFT.</p>
<p>I hope this article raises your interest in bioinformatics research, so you can help scientists fight these viral outbreaks.</p>
<h2 id="heading-what-is-sequence-alignment-and-what-is-mafft">What is Sequence Alignment? And what is MAFFT?</h2>
<p><strong>Sequence Alignment</strong> is a way of arranging DNA, RNA, or protein to identify regions of similarity that may reveal functional, structural or evolutionary relationships between the sequences. A recent <a target="_blank" href="https://onlinelibrary.wiley.com/doi/epdf/10.1002/jmv.25682">publication</a> suggested cross-species transmission from snake to human with the help of sequence alignment through MAFFT.</p>
<p><strong>MAFFT</strong> (<strong>M</strong>ultiple <strong>A</strong>lignment using <strong>F</strong>ast <strong>F</strong>ourier <strong>T</strong>ransform) is a multiple sequence alignment program published in 2002. You can use it to perform sequence alignment for RNA sequences. <strong>Coronaviruses</strong> are, for example, viruses with a single-stranded RNA enveloped in a shell derived from the cell membranes of the host.</p>
<h2 id="heading-where-can-you-obtain-rna-sequence-data">Where Can You Obtain RNA Sequence Data?</h2>
<p>The latest update of 2019-nCoV can be found on <a target="_blank" href="https://bigd.big.ac.cn/ncov#about">NGDC</a> (National Genomics Data Center of China). In this tutorial, we will analyze the <a target="_blank" href="https://www.ncbi.nlm.nih.gov/nuccore/MN938384">2019-nCoV</a> virus and the <a target="_blank" href="https://www.ncbi.nlm.nih.gov/nuccore/MK062184">SARS-CoV</a> virus found inside the NCBI (National Center for Biotechnology Information) data bank.</p>
<p>SARS-CoV, infamously know as SARS (Severe Acute Respiratory Syndrome), has resulted 774 deaths in 17 reported countries around year 2020.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/01/image-65.png" alt="Image" width="600" height="400" loading="lazy">
<em>Example RNA Sequence Data from <a target="_blank" href="https://www.ncbi.nlm.nih.gov/">NCBI</a></em></p>
<p>I have copy and pasted the data into a file with the name of the virus. It should look something like the data in the screenshot above, with an index number followed by codes in a batch size of 10, for a total of 60 codes per line, separated by spaces.</p>
<h2 id="heading-how-to-perform-sequence-alignment-on-2019-ncov-with-mafft">How to Perform Sequence Alignment on 2019-nCoV with MAFFT</h2>
<p>First, you need to install MAFFT. You can install it via Anaconda with the following commands.</p>
<p>Manual installation for different operating systems can be found on the <a target="_blank" href="https://mafft.cbrc.jp/alignment/software/">MAFFT official website</a>.</p>
<pre><code class="lang-bash">conda install mafft
</code></pre>
<p>MAFFT is fairly easy to use, but it process data in a special format. You'll need to preprocess your obtained data so that it can be aligned by MAFFT.</p>
<p>Here's the Python script that does this:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> sys
<span class="hljs-keyword">import</span> re
output = <span class="hljs-string">""</span>
<span class="hljs-keyword">for</span> filename <span class="hljs-keyword">in</span> sys.argv[<span class="hljs-number">1</span>:]:
    infile = open(filename)
    data = infile.read()
    data = <span class="hljs-string">" "</span>.join(re.split(<span class="hljs-string">"[^atcg\n]"</span>, data))
    data = data.replace(<span class="hljs-string">" "</span>, <span class="hljs-string">""</span>)
    output = output + <span class="hljs-string">"&gt;"</span> + filename + <span class="hljs-string">"\n"</span> + data + <span class="hljs-string">"\n"</span>
print(output)
outfile = open(<span class="hljs-string">'SEQUENCES.txt'</span>, <span class="hljs-string">'w+'</span>)
outfile.write(output)
</code></pre>
<p>You can save the above Python code into a file called "preprocess.py", inside the same folder as my virus RNA data. Then we can run the following bash command in the folder to preprocess the data.</p>
<pre><code class="lang-bash">python3 preprocess.py 2019-nCoV_HKU-SZ-002a_2020 icSARS-C7-MA
</code></pre>
<p>The output file called "SEQUENCES.txt" should now look like something below. The virus name is appended at the top of the file. The white space and index numbers are also stripped off.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/01/image-66.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Now you can perform Sequence Alignment with MAFFT in your Terminal with the following steps:</p>
<ol>
<li>Locate your working folder.</li>
<li>Call "mafft" inside your terminal.</li>
<li>For input file, put "SEQUENCES.txt".</li>
<li>For output file, put "output.txt".</li>
<li>Select "1" for "Clustal format" as your output format.</li>
<li>Select "1" for "auto" as your strategy.</li>
<li>Leave all other arguments blank.</li>
</ol>
<p>Here's a gif of me running this in my terminal:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/01/Jan-27-2020-18-46-10.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<p>After you hit enter, you just need to wait for MAFFT to align your RNA codes.</p>
<p>The finished product should look like something below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/01/image-67.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Note that the "-" is used to shift the codes and "*" is used to highlight similarities between the sequences.</p>
<p>Congratulations, you have just learned how to perform Sequence Alignment with MAFFT! Now you can play with the gene code and take advantage of the alignment information however you like.</p>
<p>Help Wuhan fight off deadly disease as developer, data scientists and more: </p>
<p><a target="_blank" href="https://github.com/wuhan2020/wuhan2020">https://github.com/wuhan2020/wuhan2020</a></p>
<p>A bit more about me: I'm a developer who's into all kinds of things. I've written some other fun tutorials like these:</p>
<p><a target="_blank" href="https://www.freecodecamp.org/news/ghost/#/editor/post/5ceb787ee17b4228e0185dbf/">How to create beautiful LANTERNS that ARRANGE THEMSELVES into words</a></p>
<p><a target="_blank" href="https://www.freecodecamp.org/news/ghost/#/editor/post/5ceb767ee17b4228e01833b7/">How to drop LEPRECHAUN-HATS into your website with COMPUTER VISION</a></p>
<p>Want me to write a tutorial about something? Let me know. Happy coding.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The Computer Science of Evolution: an Introduction to Genetic Algorithms ]]>
                </title>
                <description>
                    <![CDATA[ By Ben Mmari Being a computer scientist with an interest in evolution and biological processes, the topic of genetic algorithms, and more broadly, evolutionary computation is to me what a candy shop is to a 5-year-old: Heaven. The mere possibility of... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/the-computer-science-of-evolution-an-introduction-to-genetic-algorithms-b3871286c7e7/</link>
                <guid isPermaLink="false">66c36117c6c49ae59cf21ade</guid>
                
                    <category>
                        <![CDATA[ algorithms ]]>
                    </category>
                
                    <category>
                        <![CDATA[ evolution ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Genetics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Science  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 11 Apr 2019 20:49:44 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*J3BtJTlHKnx3152UKoTgYg.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Ben Mmari</p>
<p>Being a computer scientist with an interest in evolution and biological processes, the topic of genetic algorithms, and more broadly, evolutionary computation is to me what a candy shop is to a 5-year-old: Heaven. The mere possibility of being able to merge two of my interests in such a seamless manner has been extremely exhilarating, and it would be wrong for me to keep this knowledge and excitement all to myself.</p>
<p>So in an attempt to test out some of my learnings thus far, and share my findings with the rest of the world, I have decided to put together a series of articles on this topic.</p>
<p>In this post, I will provide a brief introduction to genetic algorithms and explain how they imitate the same natural processes that have been taking place on Earth for billions of years.</p>
<h4 id="heading-life-on-earth"><strong>Life on Earth</strong></h4>
<p>Over the past 3.5 billion years, mother nature, father time, evolution and natural selection have collaborated together to produce <strong>all</strong> of the specialized forms of life that we see on earth today: like the carnivorous Venus Flytrap plant; the ocean-dwelling Atlantic Flying Fish; echolocation-using bats; long-necked giraffes; super-quick cheetahs, dancing Honeybees; and of course, yours truly, the street smart Homo sapiens.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/LmZm7DjfgyLwH3RpgYrQCnWCIj0L7xB9zYvG" alt="Image" width="224" height="225" loading="lazy">
<em>The Venus Flytrap is a carnivorous plant that primarily feasts on insects and arachnids.</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/tbRcMzxleAYOcEE8r-69ZP2n6lLGunkP4QYe" alt="Image" width="318" height="159" loading="lazy">
<em>Some bats use echolocation to navigate and hunt prey and contrary to popular belief, bats are actually not blind; a species of bats known as The Flying Foxes actually have better eyesight than humans.</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/9m1HytKWrGc6wd46E5ijI2zanCsYY8OWW1Kr" alt="Image" width="800" height="368" loading="lazy">
<em>Flying Fish cannot fly in the same way that birds do, however, these fish can make powerful, self-propelled leaps out of the water where their long wing-like fins enable them to glide for considerable distances above the water’s surface.</em></p>
<p>Needless to say, life on Earth is one of, if not the most successful experiments ever run in our universe; and judging from the impressive outcomes of this experiment, it is clear that evolution is clearly onto something.</p>
<p>Recently, we humans — just one of the many end products of this process — realized that we could also take advantage of this ingenious approach to progressive problem solving, and since the 1950s, computer scientist, geneticists, mathematicians, and biologist, have attempted to mimic these biological processes through the implementation of computer simulations. With the aim of producing optimal solutions for difficult, non-trivial problems, in an efficient manner.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/LdDYa7txaI3r3aOW2UnrS-U1yyIQaBhR0RzF" alt="Image" width="800" height="376" loading="lazy"></p>
<h4 id="heading-the-blind-watchmaker"><strong>The blind watchmaker</strong></h4>
<p>One of the first books I came across that sparked my interest in the field of evolutionary biology was <a target="_blank" href="https://www.goodreads.com/book/show/117047.The_Blind_Watchmaker">The Blind Watchmaker</a>, by Richard Dawkins. In this book, Richard Dawkins explains how complex mechanisms like <a target="_blank" href="https://en.wikipedia.org/wiki/Animal_echolocation">echolocation</a> (a process that bats use to navigate, hunt and forage, also known as bio-sonar), complex structures like spiderwebs (which spiders use to attract and catch their prey), and complex instruments like the human eye (those two spherical objects that you are currently using to read this article) are simply the result of thousands, if not millions of years of evolution and adaptation.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/M35jP6QH4Qor2PeQHTErVdrxHexZe1ALKB1j" alt="Image" width="800" height="1116" loading="lazy">
_The progressive evolution of the human eye. What started off as simple photosensitive cells, evolved into a complex instrument that we often take completely for granted. The first animals with anything resembling an eye lived about 550 million years ago. And, according to one [scientist’s](https://www.pbs.org/wgbh/evolution/library/01/1/l_011_01.html" rel="noopener" target="<em>blank" title=") calculations, it would only take 364,000 years for a camera-like eye to evolve from a light-sensitive patch.</em></p>
<p>Even though these marvels of nature give the impression that they were built with a purpose from the get-go (i.e by a conscious ‘maker’), they are actually just a result of iterations upon iterations of trial and error, bundled up with ever-changing selection pressure (i.e a change in climate, habitat, or the behaviour and capabilities of predators or prey). So while they may look and behave like the outcome of precise, forward-thinking engineering, they are actually the result of a completely blind process, a process that does not know beforehand what the perfect ‘solution’ would be.</p>
<h4 id="heading-what-are-genetic-algorithms-and-why-do-we-need-them"><strong>What are genetic algorithms and why do we need them?</strong></h4>
<p>Genetic algorithms are a technique used to generate high-quality solutions to optimization and search problems, which are based on fundamental biological processes. These algorithms are used in situations where the possible range of solutions is very large, and where the more basic approaches to problem-solving like exhaustive search/brute force would consume too much time and effort.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1GLH7oZafaBQavO5i0FCqqhifqkG5fRNXT39" alt="Image" width="272" height="234" loading="lazy"></p>
<p>The <a target="_blank" href="https://en.wikipedia.org/wiki/Travelling_salesman_problem">traveling salesman problem</a> asks the following question: “Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and returns to the origin city?” It is an NP-hard problem in combinatorial optimization.</p>
<p>We can use genetic algorithms to provide high-quality solutions to this problem, at a much lower cost than the more primitive problem-solving techniques, like exhaustive search, which would require you to permute through all possible solutions.</p>
<h4 id="heading-how-do-genetic-algorithms-work"><strong>How do genetic algorithms work?</strong></h4>
<p><img src="https://cdn-media-1.freecodecamp.org/images/GWo8z30RJKWLiKSH7UOgqT8UOfFGuC0cASCq" alt="Image" width="800" height="558" loading="lazy"></p>
<p>An algorithm works by iterating through a number of steps, up until it reaches a predefined termination point. Each iteration of the genetic algorithm produces a new generation of possible solutions, which, in theory, should be an improvement on the previous generation.</p>
<p>The steps are as follows:</p>
<ol>
<li>Create an initial population of N possible solutions (the primordial soup)</li>
</ol>
<p>The first step of the algorithm is to create an initial group of solutions that serve as the base solutions in generation 0. Each solution in this initial population will carry a set of chromosomes, which are made up of a collection of genes, where each gene is assigned to one of the possible variables of the problem. It is important that the solutions in the initial population are created with randomly assigned genes, in order to have a high degree of genetic variation.</p>
<ol start="2">
<li>Rank the solutions of the population by fitness (survival of the fittest, part 1).</li>
</ol>
<p>In this step, the algorithm needs to be able to determine what makes one solution more ‘fit’ than another solution. This is determined by the fitness function. The aim of the fitness function is to evaluate the genetic viability of the solutions within the population, placing those with the most viable, favorable &amp; superior genetic traits at the top of the list.</p>
<p>In the traveling salesman problem, the fitness function could be a calculation of the total distance traveled by the solution. Where a shorter distance equates to higher fitness.</p>
<ol start="3">
<li>Cull the weaker solutions (survival of the fittest, part 2)</li>
</ol>
<p>In this step, the algorithm removes the less fit solutions from the population. The ‘fittest’ does not necessarily mean the strongest, the fastest or the fiercest, as humans usually tend to assume. Survival of the fittest simply means that the better equipped an organism is to survive in its environment, the more likely it is to live long enough to reproduce and spread its genes onto the next generation.</p>
<p>Steps 3 and 4 are collectively known as <strong>selection</strong>.</p>
<ol start="4">
<li>Breed the stronger solutions (survival of the fittest, part 3)</li>
</ol>
<p>The remaining solutions are then paired with each other in order to mate and reproduce offspring. During this process, in its most basic form, each parent will contribute a % of their genes (in nature it is a 50/50 split) to each of their offspring, where P1(G)% +P2(G)% = 100%. The process of determining which of the parents’ genes will be inherited by the offspring is known as <strong>crossover</strong>.</p>
<ol start="5">
<li>Mutate the genes of the offspring (<strong>mutation</strong>)</li>
</ol>
<p>The offspring will contain a percentage of the ‘mother’s’ genes, and a percentage of the ‘fathers’ genes and occasionally there will be a ‘mutation’ of one or more of these genes. A mutation is essentially a genetic abnormality, a copying error which causes one or more of the offspring’s genes to differ from the genes it inherited from its parents. In genetic algorithms, in some cases a mutation will increase the fitness of the offspring, in other cases, it will reduce it.</p>
<p>It is important to note that there does not need to be a mutation with each offspring, the required mutation frequency can also be a parameter of the algorithm.</p>
<p>In genetic algorithms, selection, crossover, and mutation are known as <strong>genetic operators</strong>.</p>
<ol start="6">
<li>Termination</li>
</ol>
<p>Steps 2 to 5 will be repeated up until a predefined termination point. This termination point can be one of the following:</p>
<ol>
<li>Maximum time/resource allocation reached.</li>
<li>Fixed number of generations have passed.</li>
<li>The fitness of the dominant solution cannot be surpassed by any future generations.</li>
</ol>
<h4 id="heading-solution-convergence"><strong>Solution convergence</strong></h4>
<ol>
<li>Global optimum</li>
</ol>
<p>In the ideal situation, the fittest solution will have the highest fitness value possible, i.e it will be the optimal solution, meaning that there will be no need to continue with the algorithm and produce further generations.</p>
<ol start="2">
<li>Local optimum</li>
</ol>
<p>In some cases, if the parameters of the algorithm are not reasonable, the population may tend towards a premature convergence upon a less optimal solution, which is not the global optimum that we are after, but rather a local one. Once here, continuing the algorithm and producing further generations may be futile.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/SQpPAJ72-NY7p7kJKotoBiWWYNJmJt-UmeGQ" alt="Image" width="800" height="640" loading="lazy">
<em>Global optimum vs local optimum</em></p>
<h4 id="heading-what-would-happen-if-there-were-no-mutations"><strong>What would happen if there were no mutations?</strong></h4>
<p>On first glance, mutations may seem like an unnecessary, irrelevant part of the process. But without this fundamental aspect of randomness, evolution by natural selection would be completely restricted to the genetic variety set by the initial population, and there would be no new traits introduced into the population after that. This would severely hinder nature’s problem-solving capabilities, and life on earth would not be able to ‘adapt’ to its environment, at least not physically.</p>
<p>If this was the case in our genetic algorithm, at some point in our simulation, the future generations of the population would not be able to explore part of the solution space that their predecessors did not explore. A simulation without any mutations would severely restrict the genetic variation within the population, and in most cases — depending on the initial population — prevent us from ever reaching a global optimum.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/3QFDQk2FY1jiPsvblLEuPuxzqjFMNAeawGIn" alt="Image" width="800" height="450" loading="lazy">
<em>Without mutations, we wouldn’t have mutants, and without mutants, we wouldn’t have the X-men franchise.</em></p>
<h4 id="heading-what-would-happen-if-the-population-size-was-not-large-enough"><strong>What would happen if the population size was not large enough?</strong></h4>
<p>I was recently at the Jukani Wildlife Sanctuary in Plettenberg, where I had the privilege of meeting a white tiger. He was a truly majestic animal. He was large, he looked ferocious, and, he was also 80% blind and getting progressively worse as the years went by.</p>
<p>Why was he blind? Because he is a product of generations of inbreeding. These white tigers are only produced when two tigers that carry a recessive gene controlling coat color are bred together. Thus, in order to ensure the continuation of these tigers in captivity, people have been breeding these tigers within a very limited population in order to either show them off at circuses, parade them at zoos, or keep them as household pets.</p>
<p>But one of the negative effects of inbreeding is that you severely limit the genetic variation within the species, which progressively increases the chances that harmful recessive traits will be passed onto the offspring.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/RMBs4EciPnnoKCCfrTNr4BDKJPvNKu32dRtS" alt="Image" width="800" height="450" loading="lazy">
<em>The white tiger that I met at the Jukani Wildlife Sanctuary in April 2019. He looks majestic, but he is suffering.</em></p>
<p>Even in the wild, inbreeding can still be a massive problem. Over the past few decades, the rhino population in Southern Africa has been significantly impacted due to poaching, and if the population size reaches a low enough number it would mean that maintaining the genetic diversity of these threatened rhino species would be extremely difficult. So even if poaching doesn’t completely lead them to extinction, inbreeding could.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/H3GecodM44iYchyZsSdQj1QXAusXk5oprVt-" alt="Image" width="800" height="730" loading="lazy">
_Photo by [Unsplash](https://unsplash.com/photos/xtvo0ffGKlI?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText" rel="noopener" target="_blank" title=""&gt;redcharlie on &lt;a href="https://unsplash.com/search/photos/black-rhino?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText" rel="noopener" target="<em>blank" title=").</em></p>
<p>Of course, humans are no strangers to inbreeding. One famous result of continuous inbreeding within our own species is <a target="_blank" href="http://blogs.discovermagazine.com/gnxp/2009/04/inbreeding-the-downfall-of-the-spanish-hapsburgs/#.XJO9wFMzY0o">Charles (Carlos) the II of Spain</a>.</p>
<p><em>“The Habsburg King Carlos II of Spain was sadly degenerated with an enormous misshapen head. His Habsburg jaw stood so much out that his two rows of teeth could not meet; he was unable to chew. His tongue was so large that he was barely able to speak. His intellect was similarly disabled.”</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/C4vGkUhe7UQOphhhbebMTt72DJNpuhy8nd6v" alt="Image" width="796" height="1024" loading="lazy">
<em>The Habsburg King Charles II of Spain. His father was his mother’s uncle, making Charles their son, great-nephew and first-cousin respectively.</em></p>
<p>‘Inbreeding’ in our genetic algorithm, essentially means the breeding of solutions that have a very similar genetic makeup, which, thankfully, in this case, would not result in offspring with a predisposition to any physical abnormalities. But if the <strong>population is very small</strong> and if <strong>all of the solutions share a very similar genetic makeup</strong> then the fitness of the future generations of the population will be severely restricted. Meaning that it could take much longer to converge upon a globally optimal solution if we even get there at all.</p>
<p>Inbreeding is not always a bad thing, it just depends on which stage of the simulation you are in. In very advanced stages of the simulation, as the population converges towards a global/local optima, it is obviously very hard to avoid inbreeding, because, in some cases, many of the dominant solutions will be very similar to each other, and thus, will share a lot of the same genetic traits.</p>
<h4 id="heading-wrapping-up">Wrapping up</h4>
<p>Alright, that should cover the basics. If you have any questions, requests, or genetic mutations to contribute, please leave a comment below.</p>
<p>In the next post, we will delve into some code as we look at how each of the genetic operators outlined above plays out in the world of programming. I used the Ruby programming language for the software simulation that I worked on, and in it, I show how in only a few generations, a genetic algorithm can produce a predefined word or phrase from an initial collection of complete and utter gibberish. All of the code will be hosted on Github.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Programming the genome with CRISPR ]]>
                </title>
                <description>
                    <![CDATA[ By Josh McMenemy How scientists edit genomes with the help of computers CRISPR (pronounced “crisper”) is part of a bacterial immune system evolved to ‘remember’ and remove invading viral DNA. Its name is short for ‘Clustered Regularly Interspaced Sh... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/programming-the-genome-with-crispr-bd567a214e2a/</link>
                <guid isPermaLink="false">66c35cdcadd0807b8e3fb8f8</guid>
                
                    <category>
                        <![CDATA[ coding ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Genetics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Science  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sun, 18 Feb 2018 18:19:25 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*jEBmdQVQvOeQba3Msz5f5g.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Josh McMenemy</p>
<h4 id="heading-how-scientists-edit-genomes-with-the-help-of-computers">How scientists edit genomes with the help of computers</h4>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*jEBmdQVQvOeQba3Msz5f5g.jpeg" alt="Image" width="800" height="500" loading="lazy"></p>
<p>CRISPR (pronounced “crisper”) is part of a bacterial immune system evolved to ‘remember’ and remove invading viral DNA.</p>
<p>Its name is short for ‘Clustered Regularly Interspaced Short Palindromic Repeats’. But despite its mouthful of an acronym and complex biological origins, its engineering application is straightforward. To get started, there is only one protein you need to understand — Cas9.</p>
<p>Cas9 searches for a specified DNA sequence and cuts it by breaking both strands of the DNA molecule. This protein is useful to researchers because they can ‘program’ it to target any DNA sequence. A sgRNA (‘single guide’ RNA) molecule determines the sequence that Cas9 binds to. RNA is a biological molecule similar to DNA, that can bind to proteins and DNA.</p>
<p>sgRNAs are short sequences with a constant region and variable region. The constant region attaches the sgRNA to the Cas9 protein. The variable region causes Cas9 to bind to the DNA sequence that complements it (see the diagram below).</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*HatelyoaNAjVo1jR4KWQtw.jpeg" alt="Image" width="800" height="458" loading="lazy">
<em>The Cas9 protein bound to the DNA when the PAM sequence is on the forward (top) strand. The bold sequence is the target sequence, the green sequence is the sgRNA, and the three blue characters are the PAM. The triangles show where Cas9 will cut the DNA.</em></p>
<p>Making sgRNA is cheap and fast. This allows researchers to quickly set up a Cas9 experiment that cuts any DNA sequence. Well, not actually <em>any</em> sequence. There is a small constraint: the target sequence must be flanked by the correct PAM (protospacer adjacent motif) — a short sequence of DNA.</p>
<p><a target="_blank" href="https://en.wikipedia.org/wiki/Streptococcus_pyogenes"><em>Streptococcus pyogenes</em></a> is an infectious species of bacteria. In the version of Cas9 it produces, the PAM motif is ‘NGG’, where N is any nucleotide (the ‘letters’ that make up DNA).</p>
<p>Luckily, the motif ‘NGG’ occurs roughly once every 42 basepairs in the human genome. This mean that researchers can find a target site near almost every sequence of interest.</p>
<p>Depending on the experimental set up, these cuts in the DNA can either cause a <strong>random change</strong> or a <strong>precise change</strong> to the DNA sequence (more on this later).</p>
<p>Before jumping into writing this program, I recommend studying the Cas9 diagram below.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*Bkb6hf7coqumUDNdxJ3CsQ.jpeg" alt="Image" width="800" height="458" loading="lazy">
<em>The Cas9 protein bound to a DNA sequence when the PAM sequence is on the reverse (bottom) strand.</em></p>
<p>Note that DNA and RNA have a directionality based on their chemical structure. One end of the molecule is referred to as the 5<code>(‘five-prime’) end, and the other is referred to as the 3</code> (‘three-prime’) end. This is important, because the sequences 5<code>— AGG — 3</code> is not the same as 3<code>— AGG — 5</code>.</p>
<p>By convention, DNA and RNA sequences are assumed to be written 5<code>to 3</code> unless otherwise marked. Sequences read in the 5<code>— 3</code> direction are called ‘forward’ sequences. Sequences read the other way (3<code>— 5</code>) are called ‘reverse’ sequences. This is an arbitrary convention.</p>
<p>The diagram above shows an example of Cas9 bound when the PAM is on the reverse (bottom) strand.</p>
<h3 id="heading-your-first-crispr-program">Your first CRISPR program</h3>
<h4 id="heading-the-scenario">The scenario</h4>
<p>A scientist has a DNA sequence of interest and wants a list of all CRISPR targets contained in the sequence. Finding every target by hand is tedious and error prone.</p>
<p>The scientist wants a simple program where they can input a DNA sequence and have all possible Cas9 target sites returned. The scientist would also like the cut position and PAM sequence for each target site.</p>
<pre><code>EXAMPLE INPUT (<span class="hljs-keyword">from</span> Figure <span class="hljs-number">1</span>): <span class="hljs-string">'CCACGGTTTCTGTAGCCCCATACTTTGGATG'</span>
</code></pre><pre><code>EXAMPLE OUTPUT: [{    <span class="hljs-string">'cut_pos'</span>: <span class="hljs-number">6</span>,    <span class="hljs-string">'pam_seq'</span>: <span class="hljs-string">'TGG'</span>,    <span class="hljs-string">'target_seq'</span>: <span class="hljs-string">'GTATGGGGCTACAGAAACCG'</span>,    <span class="hljs-string">'strand'</span>: <span class="hljs-string">'reverse'</span>  }, {    <span class="hljs-string">'cut_pos'</span>: <span class="hljs-number">22</span>,    <span class="hljs-string">'pam_seq'</span>: <span class="hljs-string">'TGG'</span>,    <span class="hljs-string">'target_seq'</span>: <span class="hljs-string">'GTTTCTGTAGCCCCATACTT'</span>,    <span class="hljs-string">'strand'</span>: <span class="hljs-string">'forward'</span>  }]
</code></pre><p>First, how do we find CRISPR targets in the sequence? Remember that the Cas9 protein can bind anywhere there is a ‘NGG’ motif.</p>
<p>The first step is to loop through the sequence looking for matches. When the program finds a ‘NGG’ match, we want to subtract three positions from the start of the PAM site, since that is where Cas9 cuts the DNA.</p>
<p>Then, we want to record the twenty basepairs before the PAM as the target sequence. Sounds good?</p>
<p>Well, the algorithm described above would actually miss about half of all CRISPR sites — because DNA is double stranded. This means if a ‘CCN’ is the sequence on the forward strand, then ‘NGG’ is the sequence on the reverse strand.</p>
<p>The program must also search for ‘CCN’ using similar logic for the reverse strand.</p>
<h4 id="heading-example-program">Example program</h4>
<h3 id="heading-not-all-crispr-targets-are-equal">Not all CRISPR targets are equal</h3>
<p>When CRISPR was first catching on, researchers would often pull up a sequence on their computer and pick targets by hand. Designing the optimal sgRNA has now become much more complex. Below are brief introductions to this complexity.</p>
<h4 id="heading-off-targets">Off-targets</h4>
<p>Researchers soon realized that Cas9 would sometimes bind and cut at loci that did not exactly match the target sequence. These <a target="_blank" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4320661/">off-target cuts</a> would cause unintended changes in a researcher’s experiment (or potentially a patient’s genome in the case of a therapy!)</p>
<p>To design a good guide, a program must look at the entire genome (which is approximately 3 billion nucleotides for humans) to calculate an off-target score. Researchers have also recently <a target="_blank" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4714946/">engineered the Cas9 protein</a> to have less off-target activity.</p>
<h4 id="heading-knockout">Knockout</h4>
<p>When Cas9 binds, it creates a cut by making a double strand break to the DNA molecule. Most of the time, a cell can repair this break through a biochemcial pathway (called non-homologous end joining, or NHEJ).</p>
<p>This pathway is not always perfect, and sometimes when Cas9 cuts, the repair process makes a small insertion or deletion in the DNA sequence. In a protein-coding region of DNA, these small insertions and deletions cause a frameshift mutation — which will often disrupt the protein’s function.</p>
<p>Researchers will often knockout a gene to figure out how a protein affects a specific cell function or phenotype. Creating a knockout edit <a target="_blank" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4262738/">adds extra constraints to the sgRNA design</a>, because now the guide must land in the coding region of the gene.</p>
<h4 id="heading-editing">Editing</h4>
<p>Instead of knocking out a gene, there are many times a scientist wants to make a precision edit. This is especially useful when trying to correct a disease causing a mutation. The best way to do this is still being researched. Most methods involve adding <a target="_blank" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5363683/">an extra donor piece of DNA</a>.</p>
<h4 id="heading-on-target-score">On-target score</h4>
<p>Some sgRNA sequences will cause Cas9 to cut better than others. Researchers have <a target="_blank" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4744125/">compared cutting efficiency</a> across thousands of Cas9 targets to create predictive models of a sgRNA’s cutting efficiency.</p>
<p>Microsoft even supports an <a target="_blank" href="https://github.com/MicrosoftResearch/Azimuth">open source repository</a> for ‘Machine Learning-Based Predictive Modeling of CRISPR/Cas9 guide efficiency’.</p>
<h4 id="heading-other-crispr-cas-systems">Other CRISPR-Cas systems</h4>
<p>Researchers have <a target="_blank" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4638220/">discovered CRISPR-Cas systems in other bacteria</a>. These other systems have different PAMs.</p>
<h3 id="heading-final-notes">Final notes</h3>
<p>Hope you learned something new! If you want to learn more about the biology, medical applications, commercial applications, or ethical implications of CRISPR-Cas genome engineering, then I recommend reading <a target="_blank" href="http://www.acrackincreation.com/">A Crack in Creation</a> by Jennifer Doudna and Samuel Sternberg. Jennifer Doudna is one of the original discovers of CRISPR’s underpinnings.</p>
<h4 id="heading-about-the-author">About the Author</h4>
<p>I was previously an undergraduate researcher in the <a target="_blank" href="http://gersbach.bme.duke.edu/">Gersbach</a> Lab at Duke University, and I am currently a Software Engineer at a <a target="_blank" href="http://www.synthego.com/">Synthego</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
