All files / src/parsers/utils validateBonds.ts

85.71% Statements 12/14
75% Branches 3/4
100% Functions 1/1
81.81% Lines 9/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18    5x 4722x 4722x 9588x 9588x 9588x 9588x 9585x 9585x              
//make sure bonds are actually two way
export function validateBonds (atomsarray, serialToIndex) {
  for (var i = 0, n = atomsarray.length; i < n; i++) {
      var atom = atomsarray[i];
      for(var b = 0; b < atom.bonds.length; b++) {
          var a2i = atom.bonds[b];
          var atom2 = atomsarray[a2i];
          var atomi = serialToIndex[atom.serial];
          if(atom2 && atomi) {
              var a1i = atom2.bonds.indexOf(atomi);
              Iif(a1i < 0) {
                  atom2.bonds.push(atomi);
                  atom2.bondOrder.push(atom.bondOrder[b]);
              }
          }
      }
  }
};