<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Retrieving CAS registry numbers
Step1:  Enable debug logging to make it easier to see what is going on
Step2:  A function to get the CAS registry numbers for compounds with a particular SMILES substructure
Step3:  Test some inputs
Step4:  We could potentially get a TimeoutError if there are too many results. In this case, it might be better to perform the substructure search and then get the synonyms separately
<ASSISTANT_TASK:>
Python Code:
import re
import pubchempy as pcp
Explanation: Retrieving CAS registry numbers
End of explanation
import logging
logging.getLogger('pubchempy').setLevel(logging.DEBUG)
Explanation: Enable debug logging to make it easier to see what is going on:
End of explanation
def get_substructure_cas(smiles):
    cas_rns = []
    results = pcp.get_synonyms(smiles, 'smiles', searchtype='substructure')
    for result in results:
        for syn in result.get('Synonym', []):
            match = re.match('(\d{2,7}-\d\d-\d)', syn)
            if match:
                cas_rns.append(match.group(1))
    return cas_rns
Explanation: A function to get the CAS registry numbers for compounds with a particular SMILES substructure:
End of explanation
cas_rns = get_substructure_cas('[Pb]')
print(len(cas_rns))
print(cas_rns[:10])
cas_rns = get_substructure_cas('[Se]')
print(len(cas_rns))
print(cas_rns[:10])
cas_rns = get_substructure_cas('[Ti]')
print(len(cas_rns))
print(cas_rns[:10])
cas_rns = get_substructure_cas('[Pd]')
print(len(cas_rns))
print(cas_rns[:10])
Explanation: Test some inputs:
End of explanation
cids = pcp.get_cids('[Pd]', 'smiles', searchtype='substructure')
Explanation: We could potentially get a TimeoutError if there are too many results. In this case, it might be better to perform the substructure search and then get the synonyms separately:
End of explanation
<END_TASK>