public class DnaString { int opacity = 255; Nucleotide a = new Nucleotide("A"); Nucleotide a2 = new Nucleotide("A2"); Nucleotide c = new Nucleotide("C"); Nucleotide c2 = new Nucleotide("C2"); Nucleotide g = new Nucleotide("G"); Nucleotide g2 = new Nucleotide("G2"); Nucleotide t = new Nucleotide("T"); Nucleotide t2 = new Nucleotide("T2"); Scrollbar bar = new Scrollbar(20, 450, (width-20), 10, 0.0, (width-20)); int x; //bar position Button buttonOst = new Button(485, 279, 100, 135); Button buttonFlam = new Button(595, 279, 60, 99); Button buttonTurkey = new Button(423, 319, 51, 93); Button buttonLoon = new Button(357, 319, 57, 93); Button buttonOwl = new Button(236, 319, 47, 93); Button buttonGull = new Button(300, 319, 57, 93); Button buttonWood = new Button(187, 319, 48, 93); int mode = 0; int xorigin; int yorigin; int zorigin; int size; char[] ost_basePairs = new char[0]; char[] flam_basePairs = new char[0]; char[] turk_basePairs = new char[0]; char[] loon_basePairs = new char[0]; char[] gull_basePairs = new char[0]; char[] owl_basePairs = new char[0]; char[] wood_basePairs = new char[0]; int start_char = 79; int numBpairs_disp = 2; // to be multiplied by zoom factor for screen count and scroll increment SD=2 HD=4 int totalBpairs; int f; //zoom factor //int j[] = new int[]; // x coord value for scrolling text String ostrich_data = "struthio_camelus.fasta"; String flamingo_data = "phoenicopterus_ruber(pink_flamingo).fasta"; String turkey_data = "alectura_lathami(aust_turkey).fasta"; String loon_data = "gavia_pacifica(loon).fasta"; String gull_data = "Larus_dominicanus(gull).fasta"; String owl_data = "ninox_novaeseelandiae(owl).fasta"; String woodpecker_data = "dryocopus_pileatus(woodpecker).fasta"; DnaString (int x, int y, int z){ xorigin = x; yorigin = y; zorigin = z; } void loadNucleotides() { a.loadAdenine(); a2.loadAdenine(); c.loadCytosine(); c2.loadCytosine(); g.loadGuanine(); g2.loadGuanine(); t.loadThymine(); t2.loadThymine(); } void loadTextfile() { if (mode == 1) { byte[] ost_bytes; ost_bytes = loadBytes(ostrich_data); println("there are " + ost_bytes.length + "bytes"); for (int i=0; i < ost_bytes.length; i++) { char x = char(ost_bytes[i]); if (x != '\t' && x != '\r' && x != '\f' && x != '\n' && x != ' '){ ost_basePairs = (char[])append(ost_basePairs, x); } } println(ost_basePairs.length + "bpairs"); } else if (mode == 2) { byte[] flam_bytes; flam_bytes = loadBytes(flamingo_data); println("there are " + flam_bytes.length + "bytes"); for (int i=0; i < flam_bytes.length; i++) { char x = char(flam_bytes[i]); if (x != '\t' && x != '\r' && x != '\f' && x != '\n' && x != ' '){ flam_basePairs = (char[])append(flam_basePairs, x); } } println(flam_basePairs.length + "bpairs"); } else if (mode == 3) { byte[] turk_bytes; turk_bytes = loadBytes(turkey_data); println("there are " + turk_bytes.length + "bytes"); for (int i=0; i < turk_bytes.length; i++) { char x = char(turk_bytes[i]); if (x != '\t' && x != '\r' && x != '\f' && x != '\n' && x != ' '){ turk_basePairs = (char[])append(turk_basePairs, x); } } println(turk_basePairs.length + "bpairs"); } else if (mode == 4) { byte[] loon_bytes; loon_bytes = loadBytes(loon_data); println("there are " + loon_bytes.length + "bytes"); for (int i=0; i < loon_bytes.length; i++) { char x = char(loon_bytes[i]); if (x != '\t' && x != '\r' && x != '\f' && x != '\n' && x != ' '){ loon_basePairs = (char[])append(loon_basePairs, x); } } println(loon_basePairs.length + "bpairs"); } else if (mode == 5) { byte[] gull_bytes; gull_bytes = loadBytes(gull_data); println("there are " + gull_bytes.length + "bytes"); for (int i=0; i < gull_bytes.length; i++) { char x = char(gull_bytes[i]); if (x != '\t' && x != '\r' && x != '\f' && x != '\n' && x != ' '){ gull_basePairs = (char[])append(gull_basePairs, x); } } println(gull_basePairs.length + "bpairs"); } else if (mode == 6) { byte[] owl_bytes; owl_bytes = loadBytes(owl_data); println("there are " + owl_bytes.length + "bytes"); for (int i=0; i < owl_bytes.length; i++) { char x = char(owl_bytes[i]); if (x != '\t' && x != '\r' && x != '\f' && x != '\n' && x != ' '){ owl_basePairs = (char[])append(owl_basePairs, x); } } println(owl_basePairs.length + "bpairs"); } else if (mode == 7) { byte[] wood_bytes; wood_bytes = loadBytes(woodpecker_data); println("there are " + wood_bytes.length + "bytes"); for (int i=0; i < wood_bytes.length; i++) { char x = char(wood_bytes[i]); if (x != '\t' && x != '\r' && x != '\f' && x != '\n' && x != ' '){ wood_basePairs = (char[])append(wood_basePairs, x); } } println(wood_basePairs.length + "bpairs"); } // else { // bytes = loadBytes(ostrich_data); // } } void renderText(){ if (mode == 1) { fill(0); text("Struthio camelus", 22, 357); text("Ostrich", 22, 377); text("of " + ost_basePairs.length + " base pairs", 102, 407); text((x*f) + " - " + ((x*f) + (f*numBpairs_disp)), 22, 407); } else if (mode == 2) { fill(0); text("Phoenicopterus ruber", 22, 357); text("American Flamingo", 22, 377); text("of " + flam_basePairs.length + " base pairs", 102, 407); text((x*f) + " - " + ((x*f) + (f*numBpairs_disp)), 22, 407); } else if (mode == 3) { fill(0); text("Meleagris gallopavo", 22, 357); text("Wild Turkey", 22, 377); text("of " + turk_basePairs.length + " base pairs", 102, 407); text((x*f) + " - " + ((x*f) + (f*numBpairs_disp)), 22, 407); } else if (mode == 4) { fill(0); text("Gavia pacifica", 22, 357); text("Pacific Loon", 22, 377); text("of " + loon_basePairs.length + " base pairs", 102, 407); text((x*f) + " - " + ((x*f) + (f*numBpairs_disp)), 22, 407); } else if (mode == 5) { fill(0); text("Larus canus", 22, 357); text("Common Gull", 22, 377); text("of " + gull_basePairs.length + " base pairs", 102, 407); text((x*f) + " - " + ((x*f) + (f*numBpairs_disp)), 22, 407); } else if (mode == 6) { fill(0); text("Lophostrix cristata", 22, 357); text("Crested Owl", 22, 377); text("of " + owl_basePairs.length + " base pairs", 102, 407); text((x*f) + " - " + ((x*f) + (f*numBpairs_disp)), 22, 407); } else if (mode == 7) { fill(0); text("Dryocopus pileatus", 22, 357); text("Pileated Woodpecker", 22, 377); text("of " + wood_basePairs.length + " base pairs", 102, 407); text((x*f) + " - " + ((x*f) + (f*numBpairs_disp)), 22, 407); } } void renderButtons() { buttonOst.update(); buttonOst.display("ostrich"); buttonFlam.update(); buttonFlam.display("flamingo"); buttonTurkey.update(); buttonTurkey.display("turkey"); buttonLoon.update(); buttonLoon.display("loon"); buttonGull.update(); buttonGull.display("gull"); buttonOwl.update(); buttonOwl.display("owl"); buttonWood.update(); buttonWood.display("wood"); } void renderBar() { x = int(bar.getPos()); bar.update(mouseX, mouseY); bar.display(); //println(x); } void renderMolecules_ost(){ int xcoord = this.xorigin; int ycoord = this.yorigin; int zcoord = this.zorigin; float inc_rotation = 0; int gap = 80; f = int(ost_basePairs.length/bar.sw); x = x * f; println(f); for (int i = x; i < (x + (f*numBpairs_disp)); i++) { xcoord += 0; ycoord += 50; zcoord += 0; inc_rotation += 0.3; switch(ost_basePairs[i]){ case 'A': pushMatrix(); rotateY(inc_rotation); a.AdenineDisplay(xcoord, ycoord, zcoord, radians(260), radians(10), radians(-27), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); t2.ThymineDisplay((xcoord), ycoord, zcoord, (radians(-150)), radians(210), gap); popMatrix(); break; case 'C': pushMatrix(); rotateY(inc_rotation); c.CytosineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), radians(0), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); g2.GuanineDisplay((xcoord), ycoord, zcoord, -(radians(90)), (radians(190)), radians(-30), gap); popMatrix(); break; case 'G': pushMatrix(); rotateY(inc_rotation); g.GuanineDisplay(xcoord, ycoord, zcoord, radians(-90), radians(10), radians(-30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); c2.CytosineDisplay((xcoord), ycoord, zcoord, (radians(30)-radians(180)), radians(210), (radians(0)), gap); text("C", (xcoord), ycoord, 10+zcoord); popMatrix(); break; case 'T': pushMatrix(); rotateY(inc_rotation); t.ThymineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); a2.AdenineDisplay((xcoord), ycoord, zcoord, (radians(-80)), -(radians(170)), (radians(-30)), gap); popMatrix(); break; } } } void renderMolecules_flam(){ int xcoord = this.xorigin; int ycoord = this.yorigin; int zcoord = this.zorigin; float inc_rotation = 0; int gap = 80; f = int(ost_basePairs.length/bar.sw); x = x * f; for (int i = x; i < (x + (f*numBpairs_disp)); i++) { xcoord += 0; ycoord += 50; zcoord += 0; inc_rotation += 0.3; switch(flam_basePairs[i]){ case 'A': pushMatrix(); rotateY(inc_rotation); a.AdenineDisplay(xcoord, ycoord, zcoord, radians(260), radians(10), radians(-27), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); t2.ThymineDisplay((xcoord), ycoord, zcoord, (radians(-150)), radians(210), gap); popMatrix(); break; case 'C': pushMatrix(); rotateY(inc_rotation); c.CytosineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), radians(0), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); g2.GuanineDisplay((xcoord), ycoord, zcoord, -(radians(90)), (radians(190)), radians(-30), gap); popMatrix(); break; case 'G': pushMatrix(); rotateY(inc_rotation); g.GuanineDisplay(xcoord, ycoord, zcoord, radians(-90), radians(10), radians(-30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); c2.CytosineDisplay((xcoord), ycoord, zcoord, (radians(30)-radians(180)), radians(210), (radians(0)), gap); text("C", (xcoord), ycoord, 10+zcoord); popMatrix(); break; case 'T': pushMatrix(); rotateY(inc_rotation); t.ThymineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); a2.AdenineDisplay((xcoord), ycoord, zcoord, (radians(-80)), -(radians(170)), (radians(-30)), gap); popMatrix(); break; } } } void renderMolecules_turk(){ int xcoord = this.xorigin; int ycoord = this.yorigin; int zcoord = this.zorigin; float inc_rotation = 0; int gap = 80; f = int(turk_basePairs.length/bar.sw); x = x * f; for (int i = x; i < (x + (f*numBpairs_disp)); i++) { xcoord += 0; ycoord += 50; zcoord += 0; inc_rotation += 0.3; switch(turk_basePairs[i]){ case 'A': pushMatrix(); rotateY(inc_rotation); a.AdenineDisplay(xcoord, ycoord, zcoord, radians(260), radians(10), radians(-27), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); t2.ThymineDisplay((xcoord), ycoord, zcoord, (radians(-150)), radians(210), gap); popMatrix(); break; case 'C': pushMatrix(); rotateY(inc_rotation); c.CytosineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), radians(0), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); g2.GuanineDisplay((xcoord), ycoord, zcoord, -(radians(90)), (radians(190)), radians(-30), gap); popMatrix(); break; case 'G': pushMatrix(); rotateY(inc_rotation); g.GuanineDisplay(xcoord, ycoord, zcoord, radians(-90), radians(10), radians(-30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); c2.CytosineDisplay((xcoord), ycoord, zcoord, (radians(30)-radians(180)), radians(210), (radians(0)), gap); text("C", (xcoord), ycoord, 10+zcoord); popMatrix(); break; case 'T': pushMatrix(); rotateY(inc_rotation); t.ThymineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); a2.AdenineDisplay((xcoord), ycoord, zcoord, (radians(-80)), -(radians(170)), (radians(-30)), gap); popMatrix(); break; } } } void renderMolecules_loon(){ int xcoord = this.xorigin; int ycoord = this.yorigin; int zcoord = this.zorigin; float inc_rotation = 0; int gap = 80; f = int(loon_basePairs.length/bar.sw); x = x * f; for (int i = x; i < (x + (f*numBpairs_disp)); i++) { xcoord += 0; ycoord += 50; zcoord += 0; inc_rotation += 0.3; switch(loon_basePairs[i]){ case 'A': pushMatrix(); rotateY(inc_rotation); a.AdenineDisplay(xcoord, ycoord, zcoord, radians(260), radians(10), radians(-27), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); t2.ThymineDisplay((xcoord), ycoord, zcoord, (radians(-150)), radians(210), gap); popMatrix(); break; case 'C': pushMatrix(); rotateY(inc_rotation); c.CytosineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), radians(0), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); g2.GuanineDisplay((xcoord), ycoord, zcoord, -(radians(90)), (radians(190)), radians(-30), gap); popMatrix(); break; case 'G': pushMatrix(); rotateY(inc_rotation); g.GuanineDisplay(xcoord, ycoord, zcoord, radians(-90), radians(10), radians(-30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); c2.CytosineDisplay((xcoord), ycoord, zcoord, (radians(30)-radians(180)), radians(210), (radians(0)), gap); text("C", (xcoord), ycoord, 10+zcoord); popMatrix(); break; case 'T': pushMatrix(); rotateY(inc_rotation); t.ThymineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); a2.AdenineDisplay((xcoord), ycoord, zcoord, (radians(-80)), -(radians(170)), (radians(-30)), gap); popMatrix(); break; } } } void renderMolecules_gull(){ int xcoord = this.xorigin; int ycoord = this.yorigin; int zcoord = this.zorigin; float inc_rotation = 0; int gap = 80; f = int(gull_basePairs.length/bar.sw); x = x * f; for (int i = x; i < (x + (f*numBpairs_disp)); i++) { xcoord += 0; ycoord += 50; zcoord += 0; inc_rotation += 0.3; switch(gull_basePairs[i]){ case 'A': pushMatrix(); rotateY(inc_rotation); a.AdenineDisplay(xcoord, ycoord, zcoord, radians(260), radians(10), radians(-27), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); t2.ThymineDisplay((xcoord), ycoord, zcoord, (radians(-150)), radians(210), gap); popMatrix(); break; case 'C': pushMatrix(); rotateY(inc_rotation); c.CytosineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), radians(0), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); g2.GuanineDisplay((xcoord), ycoord, zcoord, -(radians(90)), (radians(190)), radians(-30), gap); popMatrix(); break; case 'G': pushMatrix(); rotateY(inc_rotation); g.GuanineDisplay(xcoord, ycoord, zcoord, radians(-90), radians(10), radians(-30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); c2.CytosineDisplay((xcoord), ycoord, zcoord, (radians(30)-radians(180)), radians(210), (radians(0)), gap); text("C", (xcoord), ycoord, 10+zcoord); popMatrix(); break; case 'T': pushMatrix(); rotateY(inc_rotation); t.ThymineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); a2.AdenineDisplay((xcoord), ycoord, zcoord, (radians(-80)), -(radians(170)), (radians(-30)), gap); popMatrix(); break; } } } void renderMolecules_owl(){ int xcoord = this.xorigin; int ycoord = this.yorigin; int zcoord = this.zorigin; float inc_rotation = 0; int gap = 80; f = int(owl_basePairs.length/bar.sw); x = x * f; for (int i = x; i < (x + (f*numBpairs_disp)); i++) { xcoord += 0; ycoord += 50; zcoord += 0; inc_rotation += 0.3; switch(owl_basePairs[i]){ case 'A': pushMatrix(); rotateY(inc_rotation); a.AdenineDisplay(xcoord, ycoord, zcoord, radians(260), radians(10), radians(-27), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); t2.ThymineDisplay((xcoord), ycoord, zcoord, (radians(-150)), radians(210), gap); popMatrix(); break; case 'C': pushMatrix(); rotateY(inc_rotation); c.CytosineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), radians(0), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); g2.GuanineDisplay((xcoord), ycoord, zcoord, -(radians(90)), (radians(190)), radians(-30), gap); popMatrix(); break; case 'G': pushMatrix(); rotateY(inc_rotation); g.GuanineDisplay(xcoord, ycoord, zcoord, radians(-90), radians(10), radians(-30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); c2.CytosineDisplay((xcoord), ycoord, zcoord, (radians(30)-radians(180)), radians(210), (radians(0)), gap); text("C", (xcoord), ycoord, 10+zcoord); popMatrix(); break; case 'T': pushMatrix(); rotateY(inc_rotation); t.ThymineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); a2.AdenineDisplay((xcoord), ycoord, zcoord, (radians(-80)), -(radians(170)), (radians(-30)), gap); popMatrix(); break; } } } void renderMolecules_wood(){ int xcoord = this.xorigin; int ycoord = this.yorigin; int zcoord = this.zorigin; float inc_rotation = 0; int gap = 80; f = int(wood_basePairs.length/bar.sw); x = x * f; for (int i = x; i < (x + (f*numBpairs_disp)); i++) { xcoord += 0; ycoord += 50; zcoord += 0; inc_rotation += 0.3; switch(wood_basePairs[i]){ case 'A': pushMatrix(); rotateY(inc_rotation); a.AdenineDisplay(xcoord, ycoord, zcoord, radians(260), radians(10), radians(-27), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); t2.ThymineDisplay((xcoord), ycoord, zcoord, (radians(-150)), radians(210), gap); popMatrix(); break; case 'C': pushMatrix(); rotateY(inc_rotation); c.CytosineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), radians(0), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); g2.GuanineDisplay((xcoord), ycoord, zcoord, -(radians(90)), (radians(190)), radians(-30), gap); popMatrix(); break; case 'G': pushMatrix(); rotateY(inc_rotation); g.GuanineDisplay(xcoord, ycoord, zcoord, radians(-90), radians(10), radians(-30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); c2.CytosineDisplay((xcoord), ycoord, zcoord, (radians(30)-radians(180)), radians(210), (radians(0)), gap); text("C", (xcoord), ycoord, 10+zcoord); popMatrix(); break; case 'T': pushMatrix(); rotateY(inc_rotation); t.ThymineDisplay(xcoord, ycoord, zcoord, radians(-30), radians(30), gap); popMatrix(); pushMatrix(); rotateY(inc_rotation); a2.AdenineDisplay((xcoord), ycoord, zcoord, (radians(-80)), -(radians(170)), (radians(-30)), gap); popMatrix(); break; } } } }