~ubuntu-branches/ubuntu/karmic/ugene/karmic

« back to all changes in this revision

Viewing changes to src/core/src/document_format/PDBFormat.h

  • Committer: Bazaar Package Importer
  • Author(s): Ivan Efremov
  • Date: 2009-01-26 19:17:51 UTC
  • Revision ID: james.westby@ubuntu.com-20090126191751-9kqqevd3yf4o098r
Tags: upstream-1.3.2+repack
ImportĀ upstreamĀ versionĀ 1.3.2+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************
 
2
* Unipro UGENE - Integrated Bioinformatics Suite
 
3
* Copyright (C) 2008 Unipro, Russia (http://ugene.unipro.ru)
 
4
* All Rights Reserved
 
5
 
6
*     This source code is distributed under the terms of the
 
7
*     GNU General Public License. See the files COPYING and LICENSE
 
8
*     for details.
 
9
*****************************************************************/
 
10
 
 
11
#ifndef _GB2_PDB_FORMAT_H_
 
12
#define _GB2_PDB_FORMAT_H_
 
13
 
 
14
#include <core_api/DocumentFormats.h>
 
15
#include <core_api/DocumentModel.h>
 
16
#include <QtCore/QSharedDataPointer>
 
17
 
 
18
namespace GB2 {
 
19
 
 
20
class IOAdapter;
 
21
class BioStruct3D;
 
22
class AnnotationTableObject;
 
23
class DNASequenceObject;
 
24
class AtomData;
 
25
typedef QSharedDataPointer<AtomData> SharedAtom;
 
26
 
 
27
 
 
28
 
 
29
class GB2_COREAPI_EXPORT  PDBFormat : public DocumentFormat {
 
30
        Q_OBJECT
 
31
public:
 
32
        PDBFormat(QObject* p);
 
33
        virtual DocumentFormatId getFormatId() const {return BaseDocumentFormats::PLAIN_PDB;}
 
34
        virtual const QString& getFormatName() const {return formatName;}
 
35
        virtual QStringList getSupportedDocumentFileExtensions();
 
36
        virtual Document* loadExistingDocument(IOAdapterFactory* io, const QString& url, TaskStateInfo& ti, const QVariantMap& fs);
 
37
    virtual void storeDocument(Document* d, TaskStateInfo& ti, IOAdapterFactory* io = NULL, const QString& newDocURL = QString::null);
 
38
        virtual bool isObjectOpSupported(const Document* d , DocumentFormat::DocObjectOp op, GObjectType t) const;
 
39
        virtual bool isDataFormatSupported(const char* data, int size) const;
 
40
        virtual bool checkConstraints(const DocumentFormatConstraints& c) const;
 
41
        static int getElementNumberByName(const QByteArray& elementName);
 
42
        static double getAtomCovalentRadius(int atomicNumber);
 
43
    static QChar getAcronymByName(const QByteArray& name);
 
44
 
 
45
 
 
46
private:
 
47
    static const int NUM_ELEMENTS = 120; 
 
48
    QString formatName;
 
49
        static QHash<QByteArray,int> atomNumMap;
 
50
        static QHash<QByteArray, QChar> acronymNameMap;
 
51
        static double atomRadiusTable[NUM_ELEMENTS];
 
52
    
 
53
    void initUtilityMaps();
 
54
    DNASequenceObject* createSequenceObject( const QByteArray& seq, const QByteArray& sequenceName);
 
55
    void calculateBonds(BioStruct3D& bioStruct);
 
56
    void fillBioStruct3DAnnotationTable(AnnotationTableObject* ao, const BioStruct3D& bioStruct);
 
57
        
 
58
        
 
59
        class PDBParser { 
 
60
        private:
 
61
                // Data
 
62
        IOAdapter *io;
 
63
                QString currentPDBLine;
 
64
                QChar currentChainId;
 
65
                int currentMoleculeId;
 
66
        bool flagMultipleModels;
 
67
                bool flagAtomRecordPresent, flagSequenceRecordPresent;
 
68
                QHash<QChar, int> chainIndexMap;
 
69
        QMap<int, int> residueStartIndexMap;
 
70
        QMap<int, int> unreferencedResidueStartIndexMap;
 
71
        QVariantMap currentMoleculeDescr;
 
72
                // Methods
 
73
        QByteArray getSpecValue(const QByteArray& specLine, const QByteArray& valueName);
 
74
        int getChainIndexByName(const QChar& chainId);
 
75
        void parseHeader(BioStruct3D& biostruct, TaskStateInfo& ti);
 
76
                void parseCompound(BioStruct3D& biostruct, TaskStateInfo& ti);
 
77
                void parseDBRef(BioStruct3D& biostruct, TaskStateInfo& ti);
 
78
        void parseSequence(BioStruct3D& biostruct, TaskStateInfo& ti);
 
79
                void parseSecondaryStructure(BioStruct3D& biostruct, TaskStateInfo& ti);
 
80
                void parseHet(BioStruct3D& biostruct, TaskStateInfo& ti);
 
81
                void parseAtomConnections(BioStruct3D& biostruct, TaskStateInfo& ti);
 
82
                void parseAtom(BioStruct3D& biostruct, TaskStateInfo& ti);
 
83
        QByteArray getNextSpecLine();
 
84
        public:
 
85
                PDBParser(IOAdapter* io);
 
86
                void parseBioStruct3D(BioStruct3D& biostruct, TaskStateInfo& ts);
 
87
        };
 
88
 
 
89
};
 
90
 
 
91
}//namespace
 
92
 
 
93
#endif