-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #756 from prajwalkulkarni/refactor-ts-files-parser…
…-utils Refactor ts files parser utils
- Loading branch information
Showing
10 changed files
with
138 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
import { AtomSpec } from "specs"; | ||
import { bondLength } from "./bondLength"; | ||
|
||
/* | ||
* Return true if atom1 and atom2 are probably bonded to each other based on distance alone | ||
*/ | ||
|
||
export function areConnected(atom1: { elem: any; x: number; y: number; z: number; altLoc: string; }, atom2: { elem: any; x: number; y: number; z: number; altLoc: string; }) { | ||
var maxsq = bondLength(atom1.elem) + bondLength(atom2.elem); | ||
*/ | ||
export function areConnected(atom1: AtomSpec, atom2: AtomSpec) { | ||
let maxsq = bondLength(atom1.elem) + bondLength(atom2.elem); | ||
maxsq += 0.25; // fudge factor, especially important for md frames, also see 1i3d | ||
maxsq *= maxsq; | ||
|
||
var xdiff = atom1.x - atom2.x; | ||
let xdiff = atom1.x - atom2.x; | ||
xdiff *= xdiff; | ||
if (xdiff > maxsq) return false; | ||
var ydiff = atom1.y - atom2.y; | ||
let ydiff = atom1.y - atom2.y; | ||
ydiff *= ydiff; | ||
if (ydiff > maxsq) return false; | ||
var zdiff = atom1.z - atom2.z; | ||
let zdiff = atom1.z - atom2.z; | ||
zdiff *= zdiff; | ||
if (zdiff > maxsq) return false; | ||
|
||
var distSquared = xdiff + ydiff + zdiff; | ||
const distSquared = xdiff + ydiff + zdiff; | ||
|
||
if (isNaN(distSquared)) return false; | ||
else if (distSquared < 0.5) return false; // maybe duplicate position. | ||
else if (distSquared > maxsq) return false; | ||
else if ( | ||
atom1.altLoc != atom2.altLoc && | ||
atom1.altLoc != " " && | ||
atom2.altLoc != " " | ||
if ( | ||
isNaN(distSquared) || | ||
distSquared < 0.5 || | ||
distSquared > maxsq || | ||
(atom1.altLoc !== atom2.altLoc && atom1.altLoc !== " " && atom2.altLoc !== " ") | ||
) | ||
return false; // don't connect across alternate locations | ||
else return true; | ||
return false; | ||
|
||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.