@classmethod<EOL><INDENT>def from_file(cls, filename):<DEDENT>
<EOL>if filename.endswith("<STR_LIT>"):<EOL><INDENT>from molmod.io import load_cml<EOL>return load_cml(filename)[<NUM_LIT:0>]<EOL><DEDENT>elif filename.endswith("<STR_LIT>"):<EOL><INDENT>from molmod.io import FCHKFile<EOL>fchk = FCHKFile(filename, field_labels=[])<EOL>return fchk.molecule<EOL><DEDENT>elif filename.endswith("<STR_LIT>"):<EOL><INDENT>from molmod.io import load_pdb<EOL>return load_pdb(filename)<EOL><DEDENT>elif filename.endswith("<STR_LIT>"):<EOL><INDENT>from molmod.io import SDFReader<EOL>return next(SDFReader(filename))<EOL><DEDENT>elif filename.endswith("<STR_LIT>"):<EOL><INDENT>from molmod.io import XYZReader<EOL>xyz_reader = XYZReader(filename)<EOL>title, coordinates = next(xyz_reader)<EOL>return Molecule(xyz_reader.numbers, coordinates, title, symbols=xyz_reader.symbols)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % filename)<EOL><DEDENT>
Construct a molecule object read from the given file.

           The file format is inferred from the extensions. Currently supported
           formats are: ``*.cml``, ``*.fchk``, ``*.pdb``, ``*.sdf``, ``*.xyz``

           If a file contains more than one molecule, only the first one is
           read.

           Argument:
            | ``filename``  --  the name of the file containing the molecule

           Example usage::

             >>> mol = Molecule.from_file("foo.xyz")