Skip to content
TheChatArchiveThe Chat Archive
Mistralmistral-small-2506· Mistral AIHugging Face LMArena Human Preference 140K

I am a developer working in the Pharmaceutical industry, and we have students here, and…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Kimikimi-k2-0711-preview’s answer.
  1. User

    I am a developer working in the Pharmaceutical industry, and we have students here, and they are here to learn how we are developing medisin & drugs for the future. Can you make me a function in Rust that i will feed with the 'CAS number' of a chemical or a drug, and the function gives me back different ways of how to synthesise it.

  2. Mistral Assistant

    Rust Function for Drug Synthesis Pathways Based on CAS Numbers

    Here's a Rust function that takes a CAS number as input and returns potential synthesis pathways for the corresponding chemical or drug. This is a conceptual implementation that would need to be connected to a real database or API for practical use.

    use std::collections::HashMap;
    use serde::{Deserialize, Serialize};
    
    // Define a struct to represent a synthesis pathway
    #[derive(Debug, Serialize, Deserialize)]
    struct SynthesisPathway {
        steps: Vec<String>,
        yield_percentage: f32,
        conditions: String,
        references: Vec<String>,
    }
    
    // Define a struct to represent a chemical/drug entry
    #[derive(Debug, Serialize, Deserialize)]
    struct ChemicalEntry {
        cas_number: String,
        name: String,
        molecular_formula: String,
        synthesis_pathways: Vec<SynthesisPathway>,
    }
    
    // Mock database of chemicals (in a real application, this would be a proper database)
    static MOCK_DATABASE: &[ChemicalEntry] = &[
        ChemicalEntry {
            cas_number: "50-21-5".to_string(), // Aspirin
            name: "Acetylsalicylic Acid".to_string(),
            molecular_formula: "C9H8O4".to_string(),
            synthesis_pathways: vec![
                SynthesisPathway {
                    steps: vec[
                        "1. Acetylation of salicylic acid with acetic anhydride".to_string(),
                        "2. Purification by recrystallization".to_string(),
                    ],
                    yield_percentage: 85.0,
                    conditions: "Reflux in acetic anhydride, then cooling".to_string(),
                    references: vec!["J. Am. Chem. Soc. 1900, 22, 478".to_string()],
                },
                SynthesisPathway {
                    steps: vec[
                        "1. Kolbe-Schmitt reaction of phenol with CO2".to_string(),
                        "2. Methylation to form methyl salicylate".to_string(),
                        "3. Hydrolysis to salicylic acid".to_string(),
                        "4. Acetylation as above".to_string(),
                    ],
                    yield_percentage: 78.0,
                    conditions: "High pressure CO2, then methylation with dimethyl sulfate".to_string(),
                    references: vec!["Org. Synth. 1921, 1, 10".to_string()],
                },
            ],
        },
        ChemicalEntry {
            cas_number: "59-53-2".to_string(), // Penicillin G
            name: "Benzylpenicillin".to_string(),
            molecular_formula: "C16H18N2O4S".to_string(),
            synthesis_pathways: vec![
                SynthesisPathway {
                    steps: vec[
                        "1. Fermentation of Penicillium chrysogenum".to_string(),
                        "2. Purification and crystallization".to_string(),
                    ],
                    yield_percentage: 60.0,
                    conditions: "Aerobic fermentation in nutrient medium".to_string(),
                    references: vec!["Nature 1945, 156, 839".to_string()],
                },
                SynthesisPathway {
                    steps: vec[
                        "1. Chemical synthesis from 6-aminopenicillanic acid".to_string(),
                        "2. Acylation with phenylacetyl chloride".to_string(),
                    ],
                    yield_percentage: 75.0,
                    conditions: "Aqueous solution with organic solvent".to_string(),
                    references: vec!["J. Chem. Soc. 1948, 1234".to_string()],
                },
            ],
        },
        // Add more chemicals as needed
    ];
    
    /// Finds synthesis pathways for a chemical given its CAS number
    ///
    /// # Arguments
    /// * `cas_number` - The CAS number of the chemical (as string)
    ///
    /// # Returns
    /// * `Option<Vec<SynthesisPathway>>` - Some vector of pathways if found, None if not found
    pub fn get_synthesis_pathways(cas_number: &str) -> Option<Vec<SynthesisPathway>> {
        // In a real application, this would query a database or API
        MOCK_DATABASE.iter()
            .find(|entry| entry.cas_number.eq_ignore_ascii_case(cas_number))
            .map(|entry| entry.synthesis_pathways.clone())
    }
    
    /// Example usage
    fn main() {
        // Example with aspirin (CAS 50-21-5)
        if let Some(pathways) = get_synthesis_pathways("50-21-5") {
            println!("Synthesis pathways for Aspirin (CAS: 50-21-5):");
            for (i, pathway) in pathways.iter().enumerate() {
                println!("\nPathway {}:", i + 1);
                println!("Steps:");
                for step in &pathway.steps {
                    println!("- {}", step);
                }
                println!("Yield: {:.1}%", pathway.yield_percentage);
                println!("Conditions: {}", pathway.conditions);
                println!("References:");
                for ref in &pathway.references {
                    println!("- {}", ref);
                }
            }
        } else {
            println!("No synthesis pathways found for the given CAS number.");
        }
    }
    

    How to Use This Function

    1. Input: Pass a CAS number as a string (e.g., "50-21-5" for aspirin)
    2. Output: Returns an Option containing either:
      • A vector of SynthesisPathway structs with detailed information
      • None if the CAS number isn't found

    Implementation Notes

    1. Database Connection: In a real application, you would:

      • Connect to a chemical database (like PubChem, Reaxys, or an internal database)
      • Use an API to fetch synthesis information
      • Or query a local database
    2. Error Handling: The current implementation is simplified. You might want to add:

      • More detailed error types
      • Network error handling for API calls
      • Database connection management
    3. Extensibility: You could extend this to:

      • Include reaction mechanisms
      • Add safety information
      • Include yield optimization tips
      • Add regulatory information

    Would you like me to modify this implementation to better suit your specific needs in the pharmaceutical industry?

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.