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')[source]

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)[source]

Append parameter to list of parameters.

Parameters:parameter (FilterParameter) – Parameter to be added to this filter.
clone()[source]

Creates new instance with identical settings.

Returns:Exact clone of this filter item.
Return type:FilterItem
commandline(basenames=False)[source]

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()[source]
get_icon_path()[source]
get_input_compression()[source]
get_input_format()[source]
get_input_sorting()[source]
get_output_compression()[source]
get_output_format()[source]
get_output_sorting()[source]
get_parameters()[source]
is_valid()[source]
make_widget()[source]

Creates a FilterWidget visualizing all parameters of this filter.

Returns:Qt4 widget visualizing all parameters of this filter.
Return type:FilterWidget
set_command(command)[source]
set_description(desc)[source]
set_icon_path(icon_path)[source]
set_input_compression(compression)[source]
set_input_format(fileformat)[source]
set_input_sorting(sorting)[source]
set_output_compression(compression)[source]
set_output_format(fileformat)[source]
set_output_sorting(sorting)[source]
set_valid(boolean)[source]

filter_model module

Created on Tue Dec 16 09:19:24 2014

class FilterTreeModel(parent=None)[source]

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()[source]

Provides a lazy iterator over all filter items.

supportedDragActions()[source]

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)[source]

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)[source]

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)[source]

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>)[source]

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

insertItem(item, row=None)[source]

Insert filter item at specified position or append at end.

item_changed
iterate_items()[source]

Provides a lazy iterator over all filter items.

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

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>)[source]

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

supportedDragActions()[source]

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

supportedDropActions()[source]

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

takeItem(row=None)[source]

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)[source]

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__()[source]

Representation of this parameter for debugging.

Extends base method with additional attributes.

cli(basenames=False)[source]

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()[source]

Create new instance with identical settings.

Returns:An exact copy of this instance.
Return type:FilterParameter
get_extensions()[source]
set_extensions(extensions)[source]
set_value(value)[source]

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)[source]

Bases: builtins.object

Abstraction of a general command line argument for standalone filters.

Serves as base class for thresholds and filepath arguments.

__repr__()[source]

Representation of this parameter for debugging.

__str__()[source]

String representation of this parameter.

cli(basenames=False)[source]

Representation of this parameter on command line interface.

clone()[source]

Create new instance with identical settings.

Returns:Exact clone of this parameter.
Return type:FilterParameter
get_cli_name()[source]
get_default()[source]
get_description()[source]
get_form_text()[source]

Representation of this parameter in form layouts.

get_value()[source]
is_active()[source]
is_required()[source]
set_active(active=True)[source]

Activate parameter to force showing it on the commandline.

set_cli_name(cli_name)[source]
set_default(default)[source]
set_description(desc)[source]
set_required(required=True)[source]
set_value(value)[source]
class FilterSwitch(text, desc, cli_name, default, options=[True, False], value=None, required=False, active=False)[source]

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__()[source]

Representation of this parameter for debugging.

Extends base method with additional attributes.

cli(basenames=False)[source]

Representation of this parameter on command line interface.

Overrides base method to handle unset values.

clone()[source]

Create new instance with identical settings.

Returns:An exact copy of this instance.
Return type:FilterSwitch
get_option(index)[source]

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()[source]
set_options(options)[source]
set_value(value)[source]

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)[source]

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__()[source]

Representation of this parameter for debugging.

Extends base method with additional attributes.

cli(basenames=False)[source]

Representation of this parameter on command line interface.

Overrides base method to handle unset values.

clone()[source]

Create new instance with identical settings.

Returns:Exact clone of this parameter.
Return type:FilterThreshold
get_form_text()[source]

Representation of this parameter in form layouts.

Overrides base method and provides additional information on unit.

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

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)[source]

Bases: PyQt4.QtCore.QObject

Container object for workflow related data.

Takes care of serialization and validation using specialized objects.

__repr__()[source]

Representation of workflow for debugging purposes.

__str__()[source]

String representation of workflow.

Returns:Hyphenated multiline commandline to run workflow.
Return type:str
changed
clear()[source]

Empties the workflow from all filenames and filter steps.

commandline(hyphenated=False, multiline=False, batch=False, basenames=False)[source]

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()[source]

Lists supported file formats for saving and loading.

Returns:List of file extensions with leading asterisk, eg. *.ssx.
Return type:list of str
getModel()[source]
get_filename()[source]
get_in_filename()[source]
get_out_filename()[source]
get_run_compile_stats()[source]
get_run_sam2rma()[source]
infile_is_valid()[source]
input_changed
is_dirty()[source]
is_valid()[source]
list_changed
load(filename)[source]

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)[source]

Handle change of workflow model.

on_insert(mdlidx, start, end)[source]

Handle insertion of items into workflow model.

on_remove(mdlidx, start, end)[source]

Handle removal of items from workflow model.

outfile_is_valid()[source]
output_changed
save(filename=None)[source]

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()[source]

Save to file using XML serialization.

Returns:
  • bool – True if successful, otherwise False.
  • str – Error or success message.
set_dirty(dirty=True)[source]
set_filename(filename)[source]
set_in_filename(filename)[source]
set_infile_valid(valid=True)[source]
set_out_filename(filename)[source]
set_outfile_valid(valid=True)[source]
set_run_compile_stats(button_state)[source]
set_run_sam2rma(button_state)[source]
set_valid(valid=True)[source]
to_bash(filename, bash_options=<samsifter.gui.dialogs.BashOptions object at 0x7f5bd53b6400>, rma_options=<samsifter.gui.dialogs.RmaOptions object at 0x7f5bd53b6470>)[source]

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()[source]

Represent workflow as XML tree.

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

Table Of Contents

Previous topic

samsifter.gui package

Next topic

samsifter.resources package

This Page