getExperimentalData static method
- String smiles
Attempts to fetch experimental spectroscopic data from PubChem if available
Implementation
static Future<Map<String, dynamic>> getExperimentalData(String smiles) async {
try {
// Convert SMILES to PubChem CID
final molDetails = await getSmilesDetails(smiles);
final cid = molDetails['cid'];
if (cid == null) {
return {'error': 'Could not find compound in PubChem'};
}
// Try to fetch experimental spectra
final url = Uri.parse('$chempubBaseUrl/compound/cid/$cid/JSON?heading=Spectral Information');
final response = await http.get(url);
if (response.statusCode != 200) {
return {'message': 'No experimental spectral data available'};
}
final data = jsonDecode(response.body);
// Process and extract spectral data if available
// This would depend on the specific structure of PubChem's response
return {
'hasExperimentalData': true,
'cid': cid,
'data': data,
};
} catch (e) {
return {'error': 'Failed to retrieve experimental data: $e'};
}
}