diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index b6b4185e98b42199dddfcdc1e80db5d66920a8ff..f32e1658a25494d39486811f3a36c92808075eb3 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -107,6 +107,11 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' return superCellIndex.add(this.superCell.applyRotation(this.getIndex()).round()); }; + DMACell.prototype.getLatticeIndex = function(){ + var parent = lattice.getUItarget(); + return this.getAbsoluteIndex().sub(parent.get("cellsMin")); + }; + DMACell.prototype.getPosition = function(){ return this.object3D.position.clone(); }; diff --git a/js/cells/DNABrickCell.js b/js/cells/DNABrickCell.js new file mode 100644 index 0000000000000000000000000000000000000000..273e6c9330bc9467fb9e0ecc491031c0142678c3 --- /dev/null +++ b/js/cells/DNABrickCell.js @@ -0,0 +1,30 @@ +/** + * Created by aghassaei on 9/14/15. + */ + + +define(['gikCell'], function(GIKCell){ + + function DNABrickCell(json, superCell){ + GIKCell.call(this, json, superCell); + } + DNABrickCell.prototype = Object.create(GIKCell.prototype); + + DNABrickCell.prototype.getCompliment = function(nucleotide){ + if (nucleotide == "a") return "t"; + if (nucleotide == "t") return "a"; + if (nucleotide == "c") return "g"; + if (nucleotide == "g") return "c"; + if (nucleotide == "unassigned") return null; + console.warn("unknown nucleotide " + nucleotide); + return null; + }; + + DNABrickCell.prototype.getNucleotideAtIndex = function(index){ + if (this.parts && this.parts[index] && this.parts[index].getNucleotide) return this.parts[index].getNucleotide(); + return "unassigned"; + }; + + + return DNABrickCell; +}); \ No newline at end of file diff --git a/js/cells/GIKCell.js b/js/cells/GIKCell.js index f01c6aad3c9f2b4e1800cb6277af2e13410b4520..4712e50870fc458fa2b676f4d0608cf426e3d053 100644 --- a/js/cells/GIKCell.js +++ b/js/cells/GIKCell.js @@ -42,8 +42,17 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cubeCell'], }); } else if (lattice.get("partType") == "dnaStraight") { require(['dnaStraightPart'], function(PartSubclass){ + var parent = lattice.getUItarget(); + parent._parseSparseCell();//todo this should get checked + var index = self.getLatticeIndex(); + if (parent.cells[index.x][index.y][index.z+1]) var topNeighbor = parent.cells[index.x][index.y][index.z+1]; + if (parent.cells[index.x][index.y][index.z-1]) var bottomNeighbor = parent.cells[index.x][index.y][index.z-1]; for (var i=0;i<16;i++){ + var nucleotide = null; + if (topNeighbor && i<8) nucleotide = self.getCompliment(topNeighbor.getNucleotideAtIndex(i+8)); + if (bottomNeighbor && i>7) nucleotide = self.getCompliment(bottomNeighbor.getNucleotideAtIndex(i-8)); parts.push(new PartSubclass(self.index.x, self, { + nuclType: nucleotide, vertIndex: i, isBridge: false })); diff --git a/js/cells/supercells/GIKSuperCell.js b/js/cells/supercells/GIKSuperCell.js index ea7f1fe997264638e6fdd00670ddf974a48bca5f..e1dbc543bb985453aeec028ae5f3bc0c1eeda3a1 100644 --- a/js/cells/supercells/GIKSuperCell.js +++ b/js/cells/supercells/GIKSuperCell.js @@ -4,8 +4,8 @@ -define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', 'gikCell'], - function(_, THREE, three, lattice, appState, DMASuperCell, GIKCell){ +define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', 'gikCell', 'dnaBrickCell'], + function(_, THREE, three, lattice, appState, DMASuperCell, GIKCell, DNABrickCell){ var unitGeos = {}; @@ -30,6 +30,10 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', GIKSuperCell.prototype._makeSubCellForIndex = function(json, callback){ json.materialName = this.materialName; + if (lattice.get("latticeType") == "dnaBricks"){ + callback(new DNABrickCell(json, this)); + return; + } callback(new GIKCell(json, this)); }; diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index 34283712304a1992a70e60eca4674cda94a9ec80..07d342c5d06609b3894c99da997df7620c2fb150 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -171,54 +171,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre - //cells array - - _parseSparseCell: function(){ - - this.cells = [[[null]]]; - - console.log("parse cells"); - - if (this.get("numCells") == 0) { - console.warn("no cells in assembly"); - this.cells = [[[null]]]; - return; - } - - var bounds = this.calculateBoundingBox(); - this.set("denseCellsMin", bounds.min.clone().add(this.get("cellsMin"))); - var size = bounds.max.sub(bounds.min); - - //create array of nulls - var cells = []; - for (var x=0;x<size.x;x++){ - cells.push([]); - for (var y=0;y<size.y;y++){ - cells[x].push([]); - for (var z=0;z<size.z;z++){ - cells[x][y].push(null); - } - } - } - - var min = this.get("cellsMin").sub(bounds.min); - var overlap = false; - var forCAM = appState.get("currentNav") == "navAssemble"; - this._loopCells(this.sparseCells, function(cell){ - if (!cell) return; - overlap |= cell.addToDenseArray(cells, min, forCAM); - }); - this.set("overlapDetected", overlap); - - this.cells = cells; - }, - - - - - - - //3d ui diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index 610d65486498461b07e51fd17ad9a63fda82cf37..65db63519f17de6aa971e0ad80567402dfefc11f 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -447,6 +447,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre if (cell) cell.show(); }); } + this._iterCells(this.sparseCells, function(cell){ if (cell) cell.setMode(cellMode, function(){ if (--numCells <= 0) three.render(); @@ -520,6 +521,46 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return {x:xScale, y:yScale, z:zScale}; }, + _parseSparseCell: function(){ + + this.cells = [[[null]]]; + + console.log("parse cells"); + + if (this.get("numCells") == 0) { + console.warn("no cells in assembly"); + this.cells = [[[null]]]; + return; + } + + var bounds = this.calculateBoundingBox(); + this.set("denseCellsMin", bounds.min.clone().add(this.get("cellsMin"))); + var size = bounds.max.sub(bounds.min); + + //create array of nulls + var cells = []; + for (var x=0;x<size.x;x++){ + cells.push([]); + for (var y=0;y<size.y;y++){ + cells[x].push([]); + for (var z=0;z<size.z;z++){ + cells[x][y].push(null); + } + } + } + + var min = this.get("cellsMin").sub(bounds.min); + var overlap = false; + var forCAM = appState.get("currentNav") == "navAssemble"; + this._loopCells(this.sparseCells, function(cell){ + if (!cell) return; + overlap |= cell.addToDenseArray(cells, min, forCAM); + }); + this.set("overlapDetected", overlap); + + this.cells = cells; + }, + diff --git a/js/main.js b/js/main.js index a8fc4fb6366e454188ade1dd2df1f5250cc26e44..3b66cf24ac5e206bd10cdec83cc5fab41315a620 100644 --- a/js/main.js +++ b/js/main.js @@ -96,6 +96,7 @@ require.config({ compositeCell: "cells/supercells/CompositeCell", hexCell: 'cells/HexagonalCell', hexRotCell: 'cells/HexagonalRotCell', + dnaBrickCell: 'cells/DNABrickCell', //parts part: 'parts/DMAPart', diff --git a/js/parts/DNAStraightPart.js b/js/parts/DNAStraightPart.js index 4fd898efce39f136e94245701eeb95cb604f96eb..9bbd2d3fa1f14686519c6cfd0a965fdb5ba0fa0f 100644 --- a/js/parts/DNAStraightPart.js +++ b/js/parts/DNAStraightPart.js @@ -41,6 +41,10 @@ define(['underscore', 'stlLoader', 'gikPart'], function(_, THREE, GIKPart){ return 'g'; }; + DNAStraightPart.prototype.getNucleotide = function(){ + return this._nuclType; + }; + DNAStraightPart.prototype._getGeometry = function(){ if (this._isBridge) return bridgeGeo; return unitGeo;