InternBootcamp/internbootcamp/bootcamp/ChemStructure2Property/InChI2MRBootCamp.py
chenyongkang 324d068f8d refactor(internbootcamp): standardize naming conventions and improve code structure
- Rename puzzle configuration files for consistency (e.g., InChI2logP_test.json)
- Standardize class names to PascalCase (e.g., InChI2MRBootCamp -> InChI2MRbootCamp)
- Improve code structure in various bootcamp modules for better readability and maintainability
- Update import statements and file references to reflect new naming conventions
- Enhance setup.py to include rdkit dependency
2025-06-16 20:49:17 +08:00

29 lines
1.1 KiB
Python
Executable file

from rdkit import Chem
from rdkit.Chem import Crippen
from .InChI2logPBootCamp import InChI2logPbootcamp
class InChI2MRbootCamp(InChI2logPbootcamp):
def prompt_func(self, InChI) -> str:
instruction = f"Given the InChI, determine the Molar Refractivity (MR) value of the material. The InChI is: {InChI}"
instruction_following = """Let's think step by step and output the final answer within \\boxed{}.The final answer should be one float number. For example "Final Answer: \\boxed{afloat}"."""
prompt = instruction + '\n' + instruction_following
return prompt
@classmethod
def _verify_correction(cls, solution, InChI)->bool:
"""
Verify the correction of the solution.
"""
mol = Chem.MolFromInchi(InChI)
true_MR = Crippen.MolMR(mol)
solution_float = float(solution)
# Handle case where true_logp is 0
if true_MR == 0:
return abs(solution_float) <= 0.01 # Just check if solution is close to 0
else:
return abs(true_MR - solution_float)/abs(true_MR) <= 0.01