pub fn parse_mol(file_path : &str) -> Molecule {
    let contents = read_file_to_string(file_path).unwrap();
    debug_println!("{}", contents);

    // removes the header, but gets the number of atoms and saves in num_atoms
    let (result, num_atoms) = parse_header(&contents);

    let (mut contents, atoms) = parse_atom_list(result, num_atoms).unwrap();
    let mut molecule : Molecule = Molecule::new(atoms);
    debug_println!("{}", molecule.to_string());

    loop {
        // If the escape character is reached, 'M', then breaks the loop
        // In some mol files, 'A' marks the beggining of a new section after the bond adjacency
        // section
        if is_next_char_x(contents, 'M') || is_next_char_x(contents, 'A') {
            break;
        }

        let result = parse_bonds(contents).unwrap();
        contents = result.0;

        debug_println!("{}", contents);
        
        // the -1 are there because the data in the mol file starts from 1 instead of 0.
        // the bond doesnt need to be set to -1 because the default is 0
        molecule.add_bond((result.1.0 - 1) as usize, (result.1.1 - 1) as usize, result.1.2);
    }

    debug_println!("{}", molecule.to_string());

    molecule
}
// Given a valid file path of a .mol file, contructs a Molecule struct from the data in the file
// The main entry to parser
Given a valid file path of a .mol file, contructs a Molecule struct from the data in the file
The main entry to parser
Given a valid file path of a . mol file contructs a Molecule struct from the data in the file The main entry to parser
pub fn parse_mol(file_path : &str) -> Molecule {
    let contents = read_file_to_string(file_path).unwrap();
    debug_println!("{}", contents);
    // removes the header, but gets the number of atoms and saves in num_atoms
    let (result, num_atoms) = parse_header(&contents);
    let (mut contents, atoms) = parse_atom_list(result, num_atoms).unwrap();
    let mut molecule : Molecule = Molecule::new(atoms);
    debug_println!("{}", molecule.to_string());
    loop {
        // If the escape character is reached, 'M', then breaks the loop
        // In some mol files, 'A' marks the beggining of a new section after the bond adjacency
        // section
        if is_next_char_x(contents, 'M') || is_next_char_x(contents, 'A') {
            break;
        }
        let result = parse_bonds(contents).unwrap();
        contents = result.0;
        debug_println!("{}", contents);
        // the -1 are there because the data in the mol file starts from 1 instead of 0.
        // the bond doesnt need to be set to -1 because the default is 0
        molecule.add_bond((result.1.0 - 1) as usize, (result.1.1 - 1) as usize, result.1.2);
    }
    debug_println!("{}", molecule.to_string());
    molecule
}
pub fn parse_mol ( file_path : & str ) -> Molecule { let contents = read_file_to_string ( file_path ) . unwrap ( ) ; debug_println ! ( " " contents ) ; // removes the header, but gets the number of atoms and saves in num_atoms let ( result , num_atoms ) = parse_header ( & contents ) ; let ( mut contents , atoms ) = parse_atom_list ( result , num_atoms ) . unwrap ( ) ; let mut molecule : Molecule = Molecule :: new ( atoms ) ; debug_println ! ( " " molecule to_string ( ) ) ; loop { // If the escape character is reached, 'M', then breaks the loop // In some mol files, 'A' marks the beggining of a new section after the bond adjacency // section if is_next_char_x ( contents , 'M' ) || is_next_char_x ( contents , 'A' ) { break ; } let result = parse_bonds ( contents ) . unwrap ( ) ; contents = result . 0 ; debug_println ! ( " " contents ) ; // the -1 are there because the data in the mol file starts from 1 instead of 0. // the bond doesnt need to be set to -1 because the default is 0 molecule . add_bond ( ( result . 1 . 0 - 1 ) as usize , ( result . 1 . 1 - 1 ) as usize , result . 1 . 2 ) ; } debug_println ! ( " " molecule to_string ( ) ) ; molecule }
Given a valid file path of a .mol file, contructs a Molecule struct from the data in the file
The main entry to parser
Given a valid file path of a . mol file contructs a Molecule struct from the data in the file The main entry to parser
file_path
&str
file_path
&str