Skip to content

Instantly share code, notes, and snippets.

View Vini2's full-sized avatar
🧬
Focusing

Vijini Mallawaarachchi Vini2

🧬
Focusing
View GitHub Profile
# 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"
# 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",
# 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",
# 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
# 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"}
# 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")
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.
*/
/**
*
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;
@Vini2
Vini2 / SimpleDemoGA.java
Last active March 27, 2024 15:58
A simple implementation of a genetic algorithm
import java.util.Random;
/**
*
* @author Vijini
*/
//Main class
public class SimpleDemoGA {
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.