FileHandler#

class pyopenms.FileHandler#

Bases: object

Cython implementation of _FileHandler

Original C++ documentation is available here

__init__(self) None#

Methods

__init__(self)

computeFileHash

__static_FileHandler_computeFileHash(filename: Union[bytes, str, String] ) -> Union[bytes, str, String]

getOptions(self)

Access to the options for loading/storing

getType

__static_FileHandler_getType(filename: Union[bytes, str, String] ) -> int

getTypeByContent

__static_FileHandler_getTypeByContent(filename: Union[bytes, str, String] ) -> int

getTypeByFileName

__static_FileHandler_getTypeByFileName(filename: Union[bytes, str, String] ) -> int

hasValidExtension

__static_FileHandler_hasValidExtension(filename: Union[bytes, str, String] , type_: int ) -> bool

isSupported

__static_FileHandler_isSupported(type_: int ) -> bool

loadExperiment(self, in_0, in_1)

Loads a file into an MSExperiment

loadFeatures(self, in_0, in_1)

Loads a file into a FeatureMap

setOptions(self, in_0)

Sets options for loading/storing

storeExperiment(self, in_0, in_1)

Stores an MSExperiment to a file

stripExtension

__static_FileHandler_stripExtension(file: Union[bytes, str, String] ) -> Union[bytes, str, String]

swapExtension

__static_FileHandler_swapExtension(filename: Union[bytes, str, String] , new_type: int ) -> Union[bytes, str, String]

computeFileHash()#

__static_FileHandler_computeFileHash(filename: Union[bytes, str, String] ) -> Union[bytes, str, String]

getOptions(self) PeakFileOptions#

Access to the options for loading/storing

getType()#

__static_FileHandler_getType(filename: Union[bytes, str, String] ) -> int

getTypeByContent()#

__static_FileHandler_getTypeByContent(filename: Union[bytes, str, String] ) -> int

getTypeByFileName()#

__static_FileHandler_getTypeByFileName(filename: Union[bytes, str, String] ) -> int

hasValidExtension()#

__static_FileHandler_hasValidExtension(filename: Union[bytes, str, String] , type_: int ) -> bool

isSupported()#

__static_FileHandler_isSupported(type_: int ) -> bool

loadExperiment(self, in_0: bytes | str | String, in_1: MSExperiment) bool#

Loads a file into an MSExperiment

Parameters:
  • filename – The file name of the file to load

  • exp – The experiment to load the data into

  • force_type – Forces to load the file with that file type. If no type is forced, it is determined from the extension (or from the content if that fails)

  • log – Progress logging mode

  • rewrite_source_file – Set’s the SourceFile name and path to the current file. Note that this looses the link to the primary MS run the file originated from

  • compute_hash – If source files are rewritten, this flag triggers a recomputation of hash values. A SHA1 string gets stored in the checksum member of SourceFile

Returns:

true if the file could be loaded, false otherwise

Raises:

Exception: FileNotFound is thrown if the file could not be opened

Raises:

Exception: ParseError is thrown if an error occurs during parsing

loadFeatures(self, in_0: bytes | str | String, in_1: FeatureMap) bool#

Loads a file into a FeatureMap

Parameters:
  • filename – The file name of the file to load

  • map – The FeatureMap to load the data into

  • force_type – Forces to load the file with that file type. If no type is forced, it is determined from the extension (or from the content if that fails)

Returns:

true if the file could be loaded, false otherwise

Raises:

Exception: FileNotFound is thrown if the file could not be opened

Raises:

Exception: ParseError is thrown if an error occurs during parsing

setOptions(self, in_0: PeakFileOptions) None#

Sets options for loading/storing

storeExperiment(self, in_0: bytes | str | String, in_1: MSExperiment) None#

Stores an MSExperiment to a file

The file type to store the data in is determined by the file name. Supported formats for storing are mzML, mzXML, mzData and DTA2D. If the file format cannot be determined from the file name, the mzML format is used

Parameters:
  • filename – The name of the file to store the data in

  • exp – The experiment to store

  • log – Progress logging mode

Raises:

Exception: UnableToCreateFile is thrown if the file could not be written

stripExtension()#

__static_FileHandler_stripExtension(file: Union[bytes, str, String] ) -> Union[bytes, str, String]

swapExtension()#

__static_FileHandler_swapExtension(filename: Union[bytes, str, String] , new_type: int ) -> Union[bytes, str, String]