-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: xyz file parsing - nAtoms & nLines to check formatting. Created… #52
Open
adewyer
wants to merge
13
commits into
epic/SOF-5386
Choose a base branch
from
feature/SOF-5388
base: epic/SOF-5386
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ac672c8
Feat: xyz file parsing - nAtoms & nLines to check formatting. Created…
adewyer c06358a
Feat: updates to move all functions for dealing w/ parsing xyz file a…
adewyer e5e38b6
simplified atomsCount function for xyz file and updated function name…
adewyer aef4e7b
removed unused function from parsers
adewyer 65c6528
updated tests for new function naming
adewyer 6ef320c
moved functions and updated naming based on PR comments
adewyer 78572e9
moved defaultMaterialConfig to it's own file to avoid circular imports
adewyer df31214
feat: git lfs pull
tjduigna bce5e1b
remove eslint-disable-next-line import/no-cycle
adewyer 2877ebc
Merge branch 'feature/SOF-5388' of github.com:Exabyte-io/made-js into…
adewyer d859afc
updated functions for converting between formats
adewyer 8750dae
updated how we copy the default material in converting other formats …
adewyer 431a269
updates for converting xyz --> poscar without altering default material
adewyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,47 @@ | ||
// eslint-disable-next-line import/no-cycle | ||
import { defaultMaterialConfig } from "../material"; | ||
import cif from "./cif"; | ||
import espresso from "./espresso"; | ||
import poscar from "./poscar"; | ||
import xyz from "./xyz"; | ||
|
||
/** | ||
* Function returns the number of atoms in a file using the proper parser function based on the file extension. | ||
* @param {String} fileExtension | ||
* @param {String} fileContent | ||
* @returns {Number} | ||
*/ | ||
export function getNumberOfAtomsInFileByExtension(fileExtension, fileContent) { | ||
let numberOfAtoms = 0; | ||
if (fileExtension === "poscar") { | ||
numberOfAtoms = poscar.getAtomsCount(fileContent); | ||
} | ||
if (fileExtension === "xyz") { | ||
numberOfAtoms = xyz.getAtomsCount(fileContent); | ||
} | ||
return numberOfAtoms; | ||
} | ||
|
||
/** | ||
* Function converts an XYZ formatted structure as a POSCAR formatted structure | ||
* @param {String} xyzContent | ||
* @returns {String} | ||
*/ | ||
export function xyzToPoscar(xyzContent) { | ||
const xyzConfig = defaultMaterialConfig; | ||
const xyzArray = xyzContent.split(/\r?\n/); | ||
const xyzArrayBasisOnly = xyzArray.slice(2, -1); | ||
const xyzBasis = xyzArrayBasisOnly.join("\n"); | ||
xyzConfig.basis = xyz.toBasisConfig(xyzBasis); | ||
xyzConfig.basis.units = "cartesian"; | ||
return poscar.toPoscar(xyzConfig); | ||
} | ||
|
||
export default { | ||
xyz, | ||
poscar, | ||
cif, | ||
espresso, | ||
getNumberOfAtomsInFileByExtension, | ||
xyzToPoscar, | ||
}; |
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
Git LFS file not shown
Git LFS file not shown
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { xyzToPoscar } from "../../src/parsers/parsers"; | ||
import { CH4, CH4POSCAR } from "../enums"; | ||
import { assertDeepAlmostEqual } from "../utils"; | ||
|
||
describe("Parsers:XYZ", () => { | ||
it("should return the xyz file content in poscar file format", () => { | ||
assertDeepAlmostEqual(xyzToPoscar(CH4), CH4POSCAR); | ||
}); | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the
xyzToPoscar
function fromparsers/xyz.js
to this file fixed the import xyz circular dependency, but created one for defaultMaterialConfig. Previously this circular dependency was noted insideparsers/xyz.js