### Navigation

- index
- modules |
- next |
- previous |
- SamSifter 0.4.0 documentation »
- samsifter package »

# samsifter.models package

Models of entities involved in SamSifter workflows.

This package includes classes modeling entities such as

- tools/filters
- parameters for these tools
- lists and trees of tools
- entire workflows

that are used as data models for the SamSifter GUI.

## filter module

Abstraction of filters and other tools usable in POSIX pipelines.

class `FilterItem`(text=None, desc=None, icon=':/view-filter.png')

  Bases: `PyQt4.QtGui.QStandardItem`

  Representation of filter tool in item-based views.

  This class can abstract any tool that takes line-based input from STDIN, logs messages to STDERR and writes output to STDOUT. It is used to represent this tool in item-based views by means of an icon and descriptive text.

  Each item has a list of parameters as well as input and output requirements in terms file format, sort order and compression.

  `ICON_ANALYZER` = ':/x-office-spreadsheet.png'
  `ICON_CONVERTER` = ':/applications-other.png'
  `ICON_FILTER` = ':/view-filter.png'
  `ICON_SORTER` = ':/view-sort-ascending.png'
  `add_parameter`(parameter)

    Append parameter to list of parameters.

    Parameters: | parameter (FilterParameter) – Parameter to be added to this filter.

  `clone`()

    Creates new instance with identical settings.

    Returns: | Exact clone of this filter item.
    Return type: | FilterItem

  `commandline`(basenames=False)

    Prints full bash command line for filter with all parameters.

    Parameters: | basenames (bool) – Shorten file paths to filename only, defaults to False.
    Returns: | Command to execute filter with all parameters.
    Return type: | str

  `get_description`()
  `get_icon_path`()
  `get_input_compression`()
  `get_input_format`()
  `get_input_sorting`()
  `get_output_compression`()
  `get_output_format`()
  `get_output_sorting`()
  `get_parameters`()
  `is_valid`()
  `make_widget`()

    Creates a FilterWidget visualizing all parameters of this filter.

    Returns: | Qt4 widget visualizing all parameters of this filter.
    Return type: | FilterWidget

  `set_command`(command)
  `set_description`(desc)
  `set_icon_path`(icon_path)
  `set_input_compression`(compression)
  `set_input_format`(fileformat)
  `set_input_sorting`(sorting)
  `set_output_compression`(compression)
  `set_output_format`(fileformat)
  `set_output_sorting`(sorting)
  `set_valid`(boolean)

## filter_model module

Created on Tue Dec 16 09:19:24 2014

class `FilterTreeModel`(parent=None)

  Bases: `PyQt4.QtGui.QStandardItemModel`

  Item-based two-dimensional model for filter items.

  Can represent hierarchical and sequential data by implementing the QAbstractItemModel.

  TODO: allow external drag&drop of custom items, not only StandardItem

  `iterate_items`()

    Provides a lazy iterator over all filter items.

  `supportedDragActions`()

    Used to return a combination of drop actions, indicating the types of drag and drop operations that the model accepts.

    NOTE: Subclassed method, hence the unpythonic name.

class `SimpleFilterListModel`(parent=None)

  Bases: `PyQt4.QtCore.QAbstractListModel`

  One-dimensional list model for filter items.

  Represents data as a simple non-hierarchical sequence of items.

  `data`(index, role=0)

    Used to supply item data to views and delegates. Generally, models only need to supply data for Qt::DisplayRole and any application-specific Qt::AccessibleTextRole, and Qt::AccessibleDescriptionRole. See the Qt::ItemDataRole enum documentation for information about the types associated with each role.

  `flags`(index)

    Must return an appropriate combination of flags for each item. In particular, the value returned by this function must include Qt::ItemIsEditable in addition to the values applied to items in a read-only model.

    Used by other components to obtain information about each item provided by the model. In many models, the combination of flags should include Qt::ItemIsEnabled and Qt::ItemIsSelectable.

  `index`(row, col=0, parent=<PyQt4.QtCore.QModelIndex object at 0x7f5bd538b668>)

    Returns the index of the item in the model specified by the given row, column and parent index.

  `insertItem`(item, row=None)

    Insert filter item at specified position or append at end.

  `item_changed`
  `iterate_items`()

    Provides a lazy iterator over all filter items.

  `removeAll`(parent=<PyQt4.QtCore.QModelIndex object at 0x7f5bd538b7b8>)
  `removeRow`(row, parent=<PyQt4.QtCore.QModelIndex object at 0x7f5bd538b748>)
  `removeRows`(row, count, parent=<PyQt4.QtCore.QModelIndex object at 0x7f5bd538b6d8>)

    Used to remove rows and the items of data they contain from all types of model. Implementations must call beginRemoveRows() before inserting new columns into any underlying data structures, and call endRemoveRows() immediately afterwards.

  `rowCount`(parent=<PyQt4.QtCore.QModelIndex object at 0x7f5bd538b828>)

    Provides the number of rows of data exposed by the model.

  `supportedDragActions`()

    Used to return a combination of drag actions, indicating the types of drag operations that the model accepts.

  `supportedDropActions`()

    Used to return a combination of drop actions, indicating the types of drop operations that the model accepts.

  `takeItem`(row=None)

    Retrieve item and remove corresponding row.

## parameter module

Different types of command line parameters.

class `FilterFilepath`(text, desc, cli_name, default, extensions=['csv'], readable=True, writable=False, value=None, required=False, active=False)

  Bases: `samsifter.models.parameter.FilterParameter`

  Parameter setting filepath for input or output file.

  Extends parameter base class with a list of supported file extensions and requirements for read and write access.

  `__repr__`()

    Representation of this parameter for debugging.

    Extends base method with additional attributes.

  `cli`(basenames=False)

    Representation of this parameter on command line interface.

    Overrides base method to handle option for shortened filepaths.

    Parameters: | basenames (bool, optional) – Shorten file paths to filename only, defaults to False.
    Returns: | Full command line argument for this parameter with optionally shortened filenames.
    Return type: | str

  `clone`()

    Create new instance with identical settings.

    Returns: | An exact copy of this instance.
    Return type: | FilterParameter

  `get_extensions`()
  `set_extensions`(extensions)
  `set_value`(value)

    Set parameter value.

    Overrides base method to active parameter only when value has changed.

class `FilterParameter`(text, desc, cli_name, default, value=None, required=False, active=False)

  Bases: `builtins.object`

  Abstraction of a general command line argument for standalone filters.

  Serves as base class for thresholds and filepath arguments.

  `__repr__`()

    Representation of this parameter for debugging.

  `__str__`()

    String representation of this parameter.

  `cli`(basenames=False)

    Representation of this parameter on command line interface.

  `clone`()

    Create new instance with identical settings.

    Returns: | Exact clone of this parameter.
    Return type: | FilterParameter

  `get_cli_name`()
  `get_default`()
  `get_description`()
  `get_form_text`()

    Representation of this parameter in form layouts.

  `get_value`()
  `is_active`()
  `is_required`()
  `set_active`(active=True)

    Activate parameter to force showing it on the commandline.

  `set_cli_name`(cli_name)
  `set_default`(default)
  `set_description`(desc)
  `set_required`(required=True)
  `set_value`(value)

class `FilterSwitch`(text, desc, cli_name, default, options=[True, False], value=None, required=False, active=False)

  Bases: `samsifter.models.parameter.FilterParameter`

  Command line switch for a list of exclusive options.

  Extends base class with a list of selectable options. Defaults to a simple binary switch between True and False.

  `__repr__`()

    Representation of this parameter for debugging.

    Extends base method with additional attributes.

  `cli`(basenames=False)

    Representation of this parameter on command line interface.

    Overrides base method to handle unset values.

  `clone`()

    Create new instance with identical settings.

    Returns: | An exact copy of this instance.
    Return type: | FilterSwitch

  `get_option`(index)

    Get specific option out of the available options.

    Parameters: | index (int) – Index of option in list of options.
    Returns: | Desired option (or None on invalid index)
    Return type: | str

  `get_options`()
  `set_options`(options)
  `set_value`(value)

    Set parameter value.

    Overrides base method to active parameter only when value has changed.

class `FilterThreshold`(text, desc, cli_name, default=5.0, minimum=0.0, maximum=100.0, precision=2, unit=None, value=None, required=False, active=False)

  Bases: `samsifter.models.parameter.FilterParameter`

  Abstraction of a numerical command line parameter used as treshold.

  Extends filter parameter by minimum and maximum of permitted value range with variable precision and optional unit.

  `__repr__`()

    Representation of this parameter for debugging.

    Extends base method with additional attributes.

  `cli`(basenames=False)

    Representation of this parameter on command line interface.

    Overrides base method to handle unset values.

  `clone`()

    Create new instance with identical settings.

    Returns: | Exact clone of this parameter.
    Return type: | FilterThreshold

  `get_form_text`()

    Representation of this parameter in form layouts.

    Overrides base method and provides additional information on unit.

  `get_maximum`()
  `get_minimum`()
  `get_precision`()
  `get_unit`()
  `set_maximum`(maximum)
  `set_minimum`(minimum)
  `set_precision`(precision)
  `set_unit`(unit)
  `set_value`(value)

    Set value of parameter.

    Overriding base class to consider value precision.

## workflow module

Abstraction of workflows with input, tool pipeline and output.

class `Workflow`(parent=None)

  Bases: `PyQt4.QtCore.QObject`

  Container object for workflow related data.

  Takes care of serialization and validation using specialized objects.

  `__repr__`()

    Representation of workflow for debugging purposes.

  `__str__`()

    String representation of workflow.

    Returns: | Hyphenated multiline commandline to run workflow.
    Return type: | str

  `changed`
  `clear`()

    Empties the workflow from all filenames and filter steps.

  `commandline`(hyphenated=False, multiline=False, batch=False, basenames=False)

    Creates Bash-compatible commandline for entire workflow.

    Parameters: | hyphenated (bool, optional) – Enable hyphenation of entire commandline for use within variables evaluated by eval command; defaults to False. multiline (bool, optional) – Break long lines after each individual step of the workflow to improve readability; defaults to False. batch (bool, optional) – Enable use of variables that can be evaluated within code blocks like for loops or functions; defaults to False. basenames (bool, optional) – Shorten file paths to filename only; defaults to False.
    Returns: | Commandline to be run in Bash or subprocess.
    Return type: | str

  static `formats`()

    Lists supported file formats for saving and loading.

    Returns: | List of file extensions with leading asterisk, eg. `*.ssx`.
    Return type: | list of str

  `getModel`()
  `get_filename`()
  `get_in_filename`()
  `get_out_filename`()
  `get_run_compile_stats`()
  `get_run_sam2rma`()
  `infile_is_valid`()
  `input_changed`
  `is_dirty`()
  `is_valid`()
  `list_changed`
  `load`(filename)

    Load from file using XML deserialization.

    Parameters: | filename (str, optional) – Readable path to existing workflow file.
    Returns: | bool – True if successful, otherwise False. str – Error or success message.

  `on_change`(item)

    Handle change of workflow model.

  `on_insert`(mdlidx, start, end)

    Handle insertion of items into workflow model.

  `on_remove`(mdlidx, start, end)

    Handle removal of items from workflow model.

  `outfile_is_valid`()
  `output_changed`
  `save`(filename=None)

    Saves file and picks filetype depending on extension.

    Note

    Currently redundant as only XML output is supported since binary output was dropped.

    Parameters: | filename (str, optional) – Writable path of new workflow file.
    Returns: | bool – True if successful, otherwise False. str – Error or success message.

  `save_xml`()

    Save to file using XML serialization.

    Returns: | bool – True if successful, otherwise False. str – Error or success message.

  `set_dirty`(dirty=True)
  `set_filename`(filename)
  `set_in_filename`(filename)
  `set_infile_valid`(valid=True)
  `set_out_filename`(filename)
  `set_outfile_valid`(valid=True)
  `set_run_compile_stats`(button_state)
  `set_run_sam2rma`(button_state)
  `set_valid`(valid=True)
  `to_bash`(filename, bash_options=<samsifter.gui.dialogs.BashOptions object at 0x7f5bd53b6400>, rma_options=<samsifter.gui.dialogs.RmaOptions object at 0x7f5bd53b6470>)

    Write Bash script with optional batch processing capability.

    The batch variants take filenames as arguments while the standard call processes only the explicitly set input file.

    Parameters: | filename (str) – Writable path of new bash script. bash_options (BashOptions, optional) – Bash options object, defaults to new instance. rma_options (RmaOptions, optional) – SAM2RMA options object, defaults to new instance.

  `to_xml_string`()

    Represent workflow as XML tree.

    Returns: | Pretty XML string representing entire workflow structure.
    Return type: | str

  `validity_changed`

### Navigation

- index
- modules |
- next |
- previous |
- SamSifter 0.4.0 documentation »
- samsifter package »