Commit 8892b5f6 authored by Amanda Ghassaei's avatar Amanda Ghassaei

complementary strands

parent 021f9bad
...@@ -107,6 +107,11 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' ...@@ -107,6 +107,11 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', '
return superCellIndex.add(this.superCell.applyRotation(this.getIndex()).round()); 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(){ DMACell.prototype.getPosition = function(){
return this.object3D.position.clone(); return this.object3D.position.clone();
}; };
......
/**
* 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
...@@ -42,8 +42,17 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cubeCell'], ...@@ -42,8 +42,17 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cubeCell'],
}); });
} else if (lattice.get("partType") == "dnaStraight") { } else if (lattice.get("partType") == "dnaStraight") {
require(['dnaStraightPart'], function(PartSubclass){ 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++){ 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, { parts.push(new PartSubclass(self.index.x, self, {
nuclType: nucleotide,
vertIndex: i, vertIndex: i,
isBridge: false isBridge: false
})); }));
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', 'gikCell'], define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', 'gikCell', 'dnaBrickCell'],
function(_, THREE, three, lattice, appState, DMASuperCell, GIKCell){ function(_, THREE, three, lattice, appState, DMASuperCell, GIKCell, DNABrickCell){
var unitGeos = {}; var unitGeos = {};
...@@ -30,6 +30,10 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', ...@@ -30,6 +30,10 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell',
GIKSuperCell.prototype._makeSubCellForIndex = function(json, callback){ GIKSuperCell.prototype._makeSubCellForIndex = function(json, callback){
json.materialName = this.materialName; json.materialName = this.materialName;
if (lattice.get("latticeType") == "dnaBricks"){
callback(new DNABrickCell(json, this));
return;
}
callback(new GIKCell(json, this)); callback(new GIKCell(json, this));
}; };
......
...@@ -171,54 +171,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -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 //3d ui
......
...@@ -447,6 +447,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -447,6 +447,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
if (cell) cell.show(); if (cell) cell.show();
}); });
} }
this._iterCells(this.sparseCells, function(cell){ this._iterCells(this.sparseCells, function(cell){
if (cell) cell.setMode(cellMode, function(){ if (cell) cell.setMode(cellMode, function(){
if (--numCells <= 0) three.render(); if (--numCells <= 0) three.render();
...@@ -520,6 +521,46 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -520,6 +521,46 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return {x:xScale, y:yScale, z:zScale}; 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;
},
......
...@@ -96,6 +96,7 @@ require.config({ ...@@ -96,6 +96,7 @@ require.config({
compositeCell: "cells/supercells/CompositeCell", compositeCell: "cells/supercells/CompositeCell",
hexCell: 'cells/HexagonalCell', hexCell: 'cells/HexagonalCell',
hexRotCell: 'cells/HexagonalRotCell', hexRotCell: 'cells/HexagonalRotCell',
dnaBrickCell: 'cells/DNABrickCell',
//parts //parts
part: 'parts/DMAPart', part: 'parts/DMAPart',
......
...@@ -41,6 +41,10 @@ define(['underscore', 'stlLoader', 'gikPart'], function(_, THREE, GIKPart){ ...@@ -41,6 +41,10 @@ define(['underscore', 'stlLoader', 'gikPart'], function(_, THREE, GIKPart){
return 'g'; return 'g';
}; };
DNAStraightPart.prototype.getNucleotide = function(){
return this._nuclType;
};
DNAStraightPart.prototype._getGeometry = function(){ DNAStraightPart.prototype._getGeometry = function(){
if (this._isBridge) return bridgeGeo; if (this._isBridge) return bridgeGeo;
return unitGeo; return unitGeo;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment