Skip to content

Commit

Permalink
added support for asTrajectory to mmtf parser
Browse files Browse the repository at this point in the history
  • Loading branch information
arose committed Apr 29, 2016
1 parent 9745c16 commit a941dc6
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion js/ngl/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3405,7 +3405,7 @@ NGL.MmtfParser.prototype = NGL.createObject(
var numBonds, numAtoms, numGroups, numChains, numModels;
var chainsPerModel;

if( this.firstModelOnly ){
if( this.firstModelOnly || this.asTrajectory ){

numModels = 1;
numChains = sd.chainsPerModel[ 0 ];
Expand Down Expand Up @@ -3439,6 +3439,29 @@ NGL.MmtfParser.prototype = NGL.createObject(

numBonds += numGroups; // add numGroups to have space for polymer bonds

//

if( this.asTrajectory ){

for( var i = 0, il = sd.numModels; i < il; ++i ){

var frame = new Float32Array( numAtoms * 3 );
var frameAtomOffset = numAtoms * i;

for( var j = 0; j < numAtoms; ++j ){
var j3 = j * 3;
var offset = j + frameAtomOffset;
frame[ j3 ] = sd.xCoordList[ offset ];
frame[ j3 + 1 ] = sd.yCoordList[ offset ];
frame[ j3 + 2 ] = sd.zCoordList[ offset ];
}

s.frames.push( frame );

}

}

// bondStore
var bAtomIndex1 = new Uint32Array( numBonds );
var bAtomIndex2 = new Uint32Array( numBonds );
Expand Down

0 comments on commit a941dc6

Please sign in to comment.