OpenStructure
sequence_model.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_SEQUENCE_VIEWER_SEQUENCE_MODEL
20 #define OST_SEQUENCE_VIEWER_SEQUENCE_MODEL
21 
22 /*
23  Author: Stefan Scheuber
24  */
25 
26 #ifndef Q_MOC_RUN
27 
28 #include <ost/mol/chain_view.hh>
29 
30 #include <ost/seq/sequence_list.hh>
32 
33 #include <ost/gfx/entity.hh>
34 
35 #include "base_view_object.hh"
36 #include "alignment_view_object.hh"
37 #include "sequence_view_object.hh"
38 
39 #include <QAbstractTableModel>
40 #include <QItemSelection>
41 #endif
42 
43 namespace ost { namespace gui {
44 
45 class SequenceModel : public QAbstractTableModel
46 {
47  Q_OBJECT
48 
49 public:
50  SequenceModel(QObject *parent = 0);
51 
53  void InsertGfxEntity(const gfx::EntityP& entity);
54  void InsertChain(QString& name, mol::ChainView& view);
55  void InsertSequence(QString& name, seq::SequenceHandle& seq);
56  void InsertSequences(const QList<QString>& names, seq::SequenceList& list);
57 
59  void RemoveGfxEntity(const gfx::EntityP& entity);
60 
61  QModelIndexList GetModelIndexes(gfx::EntityP& entity, const mol::EntityView& view);
62  QModelIndexList GetModelIndexes(const QString& subject, const QString& sequence_name=QString());
63 
64  int GetGlobalRow(BaseViewObject* obj, int row) const;
65 
66  const QStringList& GetDisplayModes();
67  const QStringList& GetDisplayModes(const gfx::EntityP& entity);
68  const QStringList& GetDisplayModes(const seq::AlignmentHandle& alignment);
69  const QString& GetCurrentDisplayMode();
70  const QString& GetCurrentDisplayMode(const gfx::EntityP& entity);
72  void SetDisplayMode(const QString& mode);
73  void SetDisplayMode(const gfx::EntityP& entity, const QString& mode);
74  void SetDisplayMode(const seq::AlignmentHandle& alignment, const QString& mode);
75 
76  const PainterList& GetPainters(const QModelIndex& index) const;
77 
78  // abstract item model interface
79  int rowCount(const QModelIndex& parent=QModelIndex()) const;
80 
81  int columnCount(const QModelIndex& parent=QModelIndex()) const;
82 
83  QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const;
84 
85  QVariant headerData(int section, Qt::Orientation orientation,
86  int role=Qt::DisplayRole) const;
87 
88  virtual Qt::ItemFlags flags(const QModelIndex& index=QModelIndex()) const;
89  QPair<seq::AlignmentHandle, int> GetAlignmentForRow(int row);
90 
91  void EmitRowChanged(int row);
92 
93  void Clear();
94 public slots:
95  void ZoomIn();
96  void ZoomOut();
97  void DoubleClicked(const QModelIndex& index);
98  void SelectionChanged(const QItemSelection& sel, const QItemSelection& desel);
99 private:
100  int GetColumnCount() const;
101  SequenceViewObject* GetItem(const gfx::EntityP& entity);
103  BaseViewObject* GetItem(const QModelIndex& index) const;
104  QPair<int, BaseViewObject*> GetRowWithItem(int row) const;
105  QPair<int, BaseViewObject*> GetRowWithItem(const QModelIndex& index) const;
106 
107  QList<BaseViewObject*> objects_;
108  int max_columns;
109  PainterList empty_painter_list_;
110  QString empty_string_;
111  QStringList empty_string_list_;
112  QStringList display_modes_;
113  QString current_display_mode_;
114 };
115 
116 
117 }}
118 
119 #endif
void SelectionChanged(const QItemSelection &sel, const QItemSelection &desel)
void InsertChain(QString &name, mol::ChainView &view)
const QString & GetCurrentDisplayMode(const seq::AlignmentHandle &alignment)
virtual Qt::ItemFlags flags(const QModelIndex &index=QModelIndex()) const
SequenceModel(QObject *parent=0)
void SetDisplayMode(const seq::AlignmentHandle &alignment, const QString &mode)
const QString & GetCurrentDisplayMode(const gfx::EntityP &entity)
void InsertAlignment(const seq::AlignmentHandle &alignment)
const QStringList & GetDisplayModes(const gfx::EntityP &entity)
void RemoveGfxEntity(const gfx::EntityP &entity)
QPair< seq::AlignmentHandle, int > GetAlignmentForRow(int row)
int columnCount(const QModelIndex &parent=QModelIndex()) const
const PainterList & GetPainters(const QModelIndex &index) const
void SetDisplayMode(const gfx::EntityP &entity, const QString &mode)
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
const QString & GetCurrentDisplayMode()
int GetGlobalRow(BaseViewObject *obj, int row) const
QModelIndexList GetModelIndexes(const QString &subject, const QString &sequence_name=QString())
void SetDisplayMode(const QString &mode)
const QStringList & GetDisplayModes(const seq::AlignmentHandle &alignment)
void EmitRowChanged(int row)
void DoubleClicked(const QModelIndex &index)
int rowCount(const QModelIndex &parent=QModelIndex()) const
void InsertGfxEntity(const gfx::EntityP &entity)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
void InsertSequences(const QList< QString > &names, seq::SequenceList &list)
void RemoveAlignment(const seq::AlignmentHandle &alignment)
void InsertSequence(QString &name, seq::SequenceHandle &seq)
const QStringList & GetDisplayModes()
QModelIndexList GetModelIndexes(gfx::EntityP &entity, const mol::EntityView &view)
definition of ChainView
Definition: chain_view.hh:37
definition of EntityView
Definition: entity_view.hh:86
representation of a multiple sequence alignemnt consisting of two or more sequences
mutable sequence handle.
list of sequences.
def alignment(query_db, trg_db, resultDB, directory, resultDB_m8, sen=None, exe_path=None, start_sens=None, sens_steps=None, fmt=None)
Definition: mmseqs2.py:57
boost::shared_ptr< Entity > EntityP
Definition: entity_fw.hh:27
QList< Painter * > PainterList
Definition: painter.hh:48
Definition: base.dox:1