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
import java.util.concurrent.locks.Condition; | |
import java.util.concurrent.locks.Lock; | |
import java.util.concurrent.locks.ReentrantLock; | |
import static java.lang.Thread.sleep; | |
import java.util.Random; | |
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. |
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
import java.util.Random; | |
/** | |
* | |
* @author Vijini | |
*/ | |
//Main class | |
public class SimpleDemoGA { |
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
class Individual { | |
int fitness = 0; | |
int geneLength = 5; | |
int[] genes = new int[5]; | |
public Individual() { | |
Random rn = new Random(); | |
//Set genes randomly for each individual | |
for (int i = 0; i < geneLength; i++) { | |
genes[i] = rn.nextInt() % 2; |
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
import java.util.Stack; | |
import java.util.StringTokenizer; | |
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/** | |
* |
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
# Read the file and get the DNA string | |
file = open('sample_dna.txt', 'r') | |
dna = file.read() | |
# Print the original DNA string | |
print "DNA String: ", dna | |
# Print the count of each letter | |
print "Count of A: ", dna.count("A") | |
print "Count of C: ", dna.count("C") |
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
# Read the file and get the DNA string | |
file = open("sample_dna.txt", "r") | |
dna = file.read() | |
# Print the original DNA string | |
print "DNA String: ", dna | |
# Create dictionary of complementing nucleobase pairs | |
comp_pairs = {"A" : "T", "T" : "A", "G" : "C", "C" : "G"} |
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
# Read the file and get the DNA string | |
file = open('sample_dna.txt', 'r') | |
dna = file.read() | |
print "DNA: ", dna | |
rna = "" | |
# Generate the RNA string | |
for i in dna: | |
# Replace all occurrences of T with U |
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
# Read the file and get the RNA string | |
file = open('sample_rna.txt', 'r') | |
rna = file.read() | |
print "RNA String: ", rna | |
# RNA codon table | |
rna_codon = {"UUU" : "F", "CUU" : "L", "AUU" : "I", "GUU" : "V", | |
"UUC" : "F", "CUC" : "L", "AUC" : "I", "GUC" : "V", | |
"UUA" : "L", "CUA" : "L", "AUA" : "I", "GUA" : "V", |
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
# Read the file and get the DNA string | |
file = open('sample_dna.txt', 'r') | |
dna = file.read() | |
print "DNA Sequence: ", dna | |
# DNA codon table | |
protein = {"TTT" : "F", "CTT" : "L", "ATT" : "I", "GTT" : "V", | |
"TTC" : "F", "CTC" : "L", "ATC" : "I", "GTC" : "V", | |
"TTA" : "L", "CTA" : "L", "ATA" : "I", "GTA" : "V", |
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
# Import pairwise2 module | |
from Bio import pairwise2 | |
# Import format_alignment method | |
from Bio.pairwise2 import format_alignment | |
# Define two sequences to be aligned | |
X = "ACGGGT" | |
Y = "ACG" |
OlderNewer