Base (chemistry_files)

class qcip_tools.chemistry_files.ChemistryFile

Purely abstract class that implement some basic methods that any child should implement if possible.

Input methods:

  • read()

  • property() (not yet implemented)

Methods to help file recognition:

  • possible_file_extensions() (class method)

  • attempt_identification() (class method)

has_property(property_)

Checks whether a given property is available or not.

Return type:

bool

property(property_, **kwargs)
Parameters:

property (str) – the property

class qcip_tools.chemistry_files.ChemistryLogFile

Mixin for log files, for which keeps lines in self.line, allow the division of the file in chunks, and define search functions

apply_function(func, line_start=0, line_end=None, into=None, **kwargs)

Apply apply_over_list() to the lines.

Parameters:
  • lines (list) – lines of the log

  • func (callback) – function, for which the first parameter is the line, and the followings are the **kwargs.

  • line_start (int) – starting index

  • line_end (int) – end the search at some point

  • into (str) – restrict the search to a given chunk

Return type:

bool

chunk_exists(title, all_times=False)

Is a chunk in the file?

Parameters:
  • title (int|str) – the chunk to search

  • all_times (bool) – rater than stopping at the first time the link is found, go until the end and count

Returns:

the number of times the link is found (max 1 if all_times is False)

Return type:

int

classmethod possible_file_extensions()

.log and .out are so common …

Return type:

list

read(f)
Parameters:

f (file) – File

search(s, line_start=0, line_end=None, into=None)

Returns the line when the string is found in this line or -1 if nothing was found.

Return type:

int

exception qcip_tools.chemistry_files.FormatError

Raised when the format is different from what expected

exception qcip_tools.chemistry_files.PropertyNotDefined
exception qcip_tools.chemistry_files.PropertyNotPresent

Raised when a property is actually not in the file

class qcip_tools.chemistry_files.WithIdentificationMixin

Mixin for recogintion of the file by the helpers

classmethod attempt_identification(f)

Attempt to identify the file as a possible file of this type

Parameters:

f (file) – file (in read mode)

Return type:

bool

classmethod possible_file_extensions()

Return the common extention of this kind of files

Return type:

list

class qcip_tools.chemistry_files.WithMoleculeMixin

Mixin to add a molecule.

classmethod from_molecule(molecule, *args, **kwargs)

Create an object out of a molecule

Parameters:

molecule (qcip_tools.molecule.Molecule) – the molecule

Return type:

WithMoleculeMixin

get_molecule()

Get the corresponding molecular geometry.

Return type:

qcip_tools.molecule.Molecule

class qcip_tools.chemistry_files.WithOutputMixin

Mixin to add output methods.

Output methods:

  • to_string() (preferable to override)

  • write()

qcip_tools.chemistry_files.apply_over_list(lst, func, start=0, end=None, **kwargs)

Apply func() to a given element in list, and expects True if the iteration must stop, False otherwise. The prototype of func must be func(line,  current_index, **kwargs).

Parameters:
  • lst (list) – list over which the function is applied

  • func (callback) – function, for which the first parameter is the index, and the followings are the **kwargs.

  • start (int) – starting index

  • end (int) – end the search at some point

Returns:

True if it func() call for termination, False otherwise

Return type:

bool

qcip_tools.chemistry_files.chemistry_file__property__file_type(obj, **kwargs)

Get the file type trough file_type

qcip_tools.chemistry_files.chemistry_file__property__molecule(obj, **kwargs)

Get the file geometry