getSubstructureCids method
- String smiles
Searches PubChem for compounds containing the given SMILES pattern.
Returns a list of compound IDs (CIDs) matching the pattern.
Implementation
Future<List<int>> getSubstructureCids(String smiles) async {
final encodedSmiles = Uri.encodeComponent(smiles);
final url = Uri.parse(
'$chempubBaseUrl/compound/fastidentity/SMILES/$encodedSmiles/cids/JSON');
final response = await http.get(url);
if (response.statusCode != 200) {
throw Exception('Substructure search failed for SMILES: $smiles');
}
final data = jsonDecode(response.body);
return (data['IdentifierList']['CID'] as List).cast<int>().toList();
}