@@ -61,7 +61,7 @@ class Project {
6161 // Instead of atom_names and atom_elements we may have atom_species and atom_species_indices
6262 // Parse these here so the API response is still compliant with the old format
6363 const atomSpecies = topology [ 'atom_species' ] ;
64- if ( atomSpecies && ( fields . has ( 'atom_names' ) || fields . has ( 'atom_elements' ) ) ) {
64+ if ( atomSpecies && ( ! fields || fields . has ( 'atom_names' ) || fields . has ( 'atom_elements' ) ) ) {
6565 const atomNames = [ ] ;
6666 const atomElements = [ ] ;
6767 topology [ 'atom_species_indices' ] . forEach ( atomSpeciesIndex => {
@@ -80,7 +80,7 @@ class Project {
8080 const version = new Version ( topology [ 'version' ] ) ;
8181 // If we have the modern bonds system then we must modify them to match the old format
8282 const atomBonds = topology [ 'atom_bonds' ] ;
83- if ( atomBonds && ( version . greaterThan ( '0.1' ) || version . equals ( '0.1' ) ) && fields . has ( 'atom_bonds' ) ) {
83+ if ( atomBonds && ( version . greaterThan ( '0.1' ) || version . equals ( '0.1' ) ) && ( ! fields || fields . has ( 'atom_bonds' ) ) ) {
8484 const fixedBonds = Array . from ( { length : atomBonds . length } , ( ) => [ ] ) ;
8585 atomBonds . forEach ( ( bondedAtomIndices , atomIndex ) => {
8686 fixedBonds [ atomIndex ] = fixedBonds [ atomIndex ] . concat ( bondedAtomIndices ) ;
@@ -94,12 +94,12 @@ class Project {
9494 // Otherwise we must make a few changes before returning it
9595 // Check if atom charges are "per MD" and, if this is the case, then return only the values for the corresponding MD
9696 const atomCharges = topology [ 'atom_charges' ] ;
97- if ( atomCharges && atomCharges . mdmap && atomCharges . values && fields . has ( 'atom_charges' ) ) {
97+ if ( atomCharges && atomCharges . mdmap && atomCharges . values && ( ! fields || fields . has ( 'atom_charges' ) ) ) {
9898 const valueIndex = atomCharges . mdmap [ this . mdIndex ] ;
9999 topology [ 'atom_charges' ] = atomCharges . values [ valueIndex ] ;
100100 }
101101 // In case charges are in gridFS this is the moment to load them
102- if ( atomCharges && atomCharges === 'gridfs' && fields . has ( 'atom_charges' ) ) {
102+ if ( atomCharges && atomCharges === 'gridfs' && ( ! fields || fields . has ( 'atom_charges' ) ) ) {
103103 // Get the charges file descriptor
104104 const chargesDescriptor = await this . database . files . findOne (
105105 {
@@ -119,6 +119,7 @@ class Project {
119119 const parsedCharges = new Float32Array ( rawCharges . buffer ) ;
120120 topology [ 'atom_charges' ] = Array . from ( parsedCharges ) ;
121121 }
122+ if ( fields === null || fields === undefined ) return topology ;
122123 // Remove all fields which were not requested
123124 const finalTopology = { } ;
124125 fields . forEach ( field => { finalTopology [ field ] = topology [ field ] } ) ;
0 commit comments