Skip to content

Commit

Permalink
read atom serial number from PDB
Browse files Browse the repository at this point in the history
  • Loading branch information
biasmv committed Mar 8, 2016
1 parent 95a93d1 commit 289c076
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,13 @@ PDBReader.prototype = {
}
var occupancy = parseFloat(line.substr(54,6).trim());
var tempFactor = parseFloat(line.substr(60,6).trim());
var serial = parseInt(line.substr(6,5).trim(), 10);
var atom = this._currRes.addAtom(atomName, pos, element, isHetatm,
isNaN(occupancy) ? null : occupancy,
isNaN(tempFactor) ? null : tempFactor);
isNaN(tempFactor) ? null : tempFactor,
serial);
// in case parseConect records is set to true, store away the atom serial
if (this._options.conectRecords) {
var serial = parseInt(line.substr(6,5).trim(), 10);
this._serialToAtomMap[serial] = atom;
}
return true;
Expand Down
6 changes: 5 additions & 1 deletion src/mol/atom.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ AtomBase.prototype = {
};

function Atom(residue, name, pos, element, index, isHetatm,
occupancy, tempFactor) {
occupancy, tempFactor, serial) {
AtomBase.call(this);
this._properties = {};
this._residue = residue;
Expand All @@ -77,6 +77,7 @@ function Atom(residue, name, pos, element, index, isHetatm,
this._element = element;
this._occupancy = occupancy !== undefined ? occupancy : null;
this._tempFactor = tempFactor !== undefined ? tempFactor : null;
this._serial = serial|0;
}

utils.derive(Atom, AtomBase, {
Expand Down Expand Up @@ -104,6 +105,8 @@ utils.derive(Atom, AtomBase, {

tempFactor : function() { return this._tempFactor; },

serial : function() { return this._serial; },

isHetatm : function() {
return this._isHetatm;
},
Expand Down Expand Up @@ -139,6 +142,7 @@ utils.derive(AtomView, AtomBase, {
index : function() { return this._atom.index(); },
occupancy : function() { return this._atom.occupancy(); },
tempFactor : function() { return this._atom.tempFactor(); },
serial : function() { return this._serial; },
qualifiedName : function() {
return this._atom.qualifiedName();
},
Expand Down
4 changes: 2 additions & 2 deletions src/mol/residue.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ utils.derive(Residue, ResidueBase, {

full : function() { return this; },

addAtom : function(name, pos, element, isHetatm, occupancy, tempFactor) {
addAtom : function(name, pos, element, isHetatm, occupancy, tempFactor, serial) {
var atom = new Atom(this, name, pos, element,
this.structure().nextAtomIndex(),
isHetatm, occupancy, tempFactor);
isHetatm, occupancy, tempFactor, serial|0);
this._atoms.push(atom);
return atom;
},
Expand Down

0 comments on commit 289c076

Please sign in to comment.