Abstract Analyser¶
Usage¶
This class provides some common features often required in analysers. Currently, the main feature is the filtering of clusters based on size, ratio, identified spectra, etc.
If you develop an analyser simply create a child of this class:
from spectra_cluster.analyser.common import AbstractAnalyser
class MyAnalyser(AbstractAnalyser):
"""
This Analyser counts the total number of
clusters
"""
def __init__(self):
# call the AbstractAnalyser's init class
# to set all filtering variables to their
# default values.
super().__init__()
# initialise you're class' instance
# variables self.number_of_clusters = 0
def process_cluster(self, cluster):
# This function must be implemented by all
# analysers
# first, check whether this cluster should
# be processed at all
if self._ignore_cluster(cluster):
return
# count the cluster
self.number_of_clusters += 1
Class Definition¶
-
class
spectra_cluster.analyser.common.AbstractAnalyser¶ Base class for all analysers.
This class mainly provides helper functions for filtering clusters based on size, ratio, identified spectra, etc.
Additionally, every child class must implement the process_cluster(Cluster) function.
Its init functions sets the following member variables so that all clusters are accepted.
Variables: - min_size – Minimal size of the cluster
- max_size – Maximum size of the cluster
- min_ratio – Minimum I/L agnostic ratio
- max_ratio – Maximum I/L agnostic ratio
- min_identified_spectra – Minimal identified spectra
- max_identified_spectra – Maximum identified spectra
- min_unidentified_spectra – Minimal unidentified spectra
- max_unidentified_spectra – Maximum unidentified spectra
-
__init__()¶ Initialises the default parameters to filter clusters.
-
_ignore_cluster(cluster)¶ Tests whether the passed cluster should be ignored
This function assess the class’ instance variables (min size, max size, etc.) to test whether the passed cluster should be ignored for further processing.
Param: cluster Cluster to test. Returns: Boolean indicating whether the cluster should be ignored.
-
process_cluster(cluster)¶ Processes the defined cluster.
Parameters: cluster – Cluster to process.