Skip to content

Commit

Permalink
fix(PDBReader): Apply uniform reader API
Browse files Browse the repository at this point in the history
BREAKING CHANGE: PDBReader: parseText => parseAsText
  • Loading branch information
jourdain committed Feb 7, 2018
1 parent a89299e commit d0329a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
1 change: 1 addition & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Add more consistency in Readers
- ElevationReader
- MTLReader
- OBJReader
- PDBReader


## From 4.x to 5
Expand Down
25 changes: 7 additions & 18 deletions Sources/IO/Misc/PDBReader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ function vtkPDBReader(publicAPI, model) {
}

// Internal method to fetch Array
function fetchPDB(url) {
const { compression, progressCallback } = model;
return model.dataAccessHelper.fetchText(publicAPI, url, {
compression,
progressCallback,
});
function fetchPDB(url, option) {
return model.dataAccessHelper.fetchText(publicAPI, url, option);
}

// Set DataSet url
publicAPI.setUrl = (url) => {
publicAPI.setUrl = (url, option) => {
if (url.indexOf('.pdb') === -1) {
model.baseURL = url;
model.url = `${url}`; // `${url}/index.pdb`;
Expand All @@ -41,13 +37,14 @@ function vtkPDBReader(publicAPI, model) {
}

// Fetch metadata
return publicAPI.loadData();
return publicAPI.loadData(option);
};

// Fetch the actual data arrays
publicAPI.loadData = () => fetchPDB(model.url).then(publicAPI.parseText);
publicAPI.loadData = (option) =>
fetchPDB(model.url, option).then(publicAPI.parseAsText);

publicAPI.parseText = (txt) => {
publicAPI.parseAsText = (txt) => {
model.pdb = txt;
model.molecule = [];
model.molecule = model.pdb.split('\n');
Expand Down Expand Up @@ -183,14 +180,6 @@ export function extend(publicAPI, model, initialValues = {}) {

// Object methods
vtkPDBReader(publicAPI, model);

// To support destructuring
if (!model.compression) {
model.compression = null;
}
if (!model.progressCallback) {
model.progressCallback = null;
}
}

// ----------------------------------------------------------------------------
Expand Down

0 comments on commit d0329a4

Please sign in to comment.