Created
March 23, 2015 18:23
-
-
Save JFFail/96c8b3cc4b4a06653fec to your computer and use it in GitHub Desktop.
Solution To Reddit Daily Programmer #207 - Generating DNA Sequences
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
DNA Sequence - Daily Programmer #207 | |
http://www.reddit.com/r/dailyprogrammer/comments/2zyipu/20150323_challenge_207_easy_bioinformatics_1_dna/ | |
#> | |
#Main input. | |
$inputSequence = "A A T G C C T A T G G C" | |
#Hash defining the pairs. | |
$pairs = @{'A'='T';'T'='A';'G'='C';'C'='G'} | |
#Create a variable to store the results. | |
$result = "" | |
#Check for the item as a key. | |
$length = $inputSequence.Length | |
#Loop through each item. | |
for($i = 0; $i -lt $length; $i++) | |
{ | |
#Get the current value and cast it as a string. | |
$current = $inputSequence[$i] | |
$current = [string]$current | |
#Check if the value is a space or not and append accordingly to results. | |
if($pairs.ContainsKey($current)) | |
{ | |
$result += $pairs[$current] | |
} | |
else | |
{ | |
$result += " " | |
} | |
} | |
#Run through the final output. | |
Write-Host "Original sequence: $inputSequence" | |
Write-Host "Pairing sequence: $result" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment