Skip to content

Instantly share code, notes, and snippets.

@JFFail
Created March 23, 2015 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JFFail/96c8b3cc4b4a06653fec to your computer and use it in GitHub Desktop.
Save JFFail/96c8b3cc4b4a06653fec to your computer and use it in GitHub Desktop.
Solution To Reddit Daily Programmer #207 - Generating DNA Sequences
<#
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