⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qualifiers.hpp

📁 ncbi源码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: qualifiers.hpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 19:39:59  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.12 * PRODUCTION * =========================================================================== */#ifndef OBJTOOLS_FORMAT_ITEMS___QUALIFIERS__HPP#define OBJTOOLS_FORMAT_ITEMS___QUALIFIERS__HPP/*  $Id: qualifiers.hpp,v 1000.1 2004/06/01 19:39:59 gouriano Exp $* ===========================================================================**                            PUBLIC DOMAIN NOTICE*               National Center for Biotechnology Information**  This software/database is a "United States Government Work" under the*  terms of the United States Copyright Act.  It was written as part of*  the author's official duties as a United States Government employee and*  thus cannot be copyrighted.  This software/database is freely available*  to the public for use. The National Library of Medicine and the U.S.*  Government have not placed any restriction on its use or reproduction.**  Although all reasonable efforts have been taken to ensure the accuracy*  and reliability of the software and data, the NLM and the U.S.*  Government do not and cannot warrant the performance or results that*  may be obtained by using this software or data. The NLM and the U.S.*  Government disclaim all warranties, express or implied, including*  warranties of performance, merchantability or fitness for any particular*  purpose.**  Please cite the author in any work or product based on this material.** ===========================================================================** Author:  Aaron Ucko, Mati Shomrat** File Description:*   new (early 2003) flat-file generator -- qualifier types*   (mainly of interest to implementors)**/#include <corelib/ncbistd.hpp>#include <corelib/ncbiobj.hpp>#include <objects/general/Dbtag.hpp>#include <objects/general/User_object.hpp>#include <objects/general/User_field.hpp>#include <objects/pub/Pub_set.hpp>#include <objects/seqfeat/Seq_feat.hpp>#include <objects/seqfeat/Cdregion.hpp>#include <objects/seqfeat/BioSource.hpp>#include <objects/seqfeat/OrgMod.hpp>#include <objects/seqfeat/SubSource.hpp>#include <objects/seqfeat/Gb_qual.hpp>#include <objects/seqfeat/Code_break.hpp>#include <objects/seqfeat/Trna_ext.hpp>#include <objects/seq/Seq_inst.hpp>#include <objects/seq/MolInfo.hpp>#include <objtools/format/items/flat_seqloc.hpp>#include <objtools/format/items/flat_qual_slots.hpp>BEGIN_NCBI_SCOPEBEGIN_SCOPE(objects)class CBioseqContext;/////////////////////////////////////////////////////////////////////////////// low-level formatted qualifierclass CFormatQual : public CObject{public:    enum EStyle {        eEmpty,   // /name [value ignored]        eQuoted,  // /name="value"        eUnquoted // /name=value    };    typedef EStyle  TStyle;    CFormatQual(const string& name,              const string& value,               const string& prefix,              const string& suffix,              TStyle style = eQuoted);    CFormatQual(const string& name,              const string& value,              TStyle style = eQuoted);    const string& GetName  (void) const { return m_Name;   }    const string& GetValue (void) const { return m_Value;  }    TStyle        GetStyle (void) const { return m_Style;  }    const string& GetPrefix(void) const { return m_Prefix; }    const string& GetSuffix(void) const { return m_Suffix; }private:    string m_Name, m_Value, m_Prefix, m_Suffix;    TStyle m_Style;};typedef CRef<CFormatQual>      TFlatQual;typedef vector<TFlatQual>    TFlatQuals;/////////////////////////////////////////////////////////////////////////////// abstract qualifier valueclass IFlatQVal : public CObject{public:    enum EFlags {        fIsNote   = 0x1,        fIsSource = 0x2    };    typedef int TFlags; // binary OR of EFlags    static const string kSemicolon;  // "; "    static const string kComma;      // ", "    static const string kEOL;        // "\n" - end of line    virtual void Format(TFlatQuals& quals, const string& name,        CBioseqContext& ctx, TFlags flags = 0) const = 0;protected:    typedef CFormatQual::TStyle   TStyle;    IFlatQVal(const string* pfx = &kEmptyStr, const string* sfx = &kEmptyStr)        : m_Prefix(pfx), m_Suffix(sfx)    { }    /*    static void x_AddFQ(TFlatQuals& q, const string& n, const string& v,        const srting& sfx, const string& pfx        TStyle st = CFormatQual::eQuoted) {        q.push_back(TFlatQual(new CFormatQual(n, v, pfx, sfx, st)));     }    */      void x_AddFQ(TFlatQuals& q, const string& n, const string& v,        TStyle st = CFormatQual::eQuoted) const {        q.push_back(TFlatQual(new CFormatQual(n, v, *m_Prefix, *m_Suffix, st)));     }    mutable const string* m_Prefix;    mutable const string* m_Suffix;};/////////////////////////////////////////////////////////////////////////////// qualifiers containertemplate<typename Key>class CQualContainer : public CObject{public:    // typedef    typedef multimap<Key, CConstRef<IFlatQVal> > TQualMMap;    typedef typename TQualMMap::const_iterator   const_iterator;    typedef typename TQualMMap::iterator         iterator;    typedef typename TQualMMap::size_type        size_type;    // constructor    CQualContainer(void) {}        iterator begin(void) { return m_Quals.begin(); }    const_iterator begin(void) const { return m_Quals.begin(); }    iterator end(void) { return m_Quals.end(); }    const_iterator end(void) const { return m_Quals.end(); }        void AddQual(const Key& key, const IFlatQVal* value) {        typedef typename TQualMMap::value_type TMapPair;        m_Quals.insert(TMapPair(key, CConstRef<IFlatQVal>(value)));    }        bool HasQual(const Key& key) const {        return Find(key) != m_Quals.end();    }    pair<iterator, iterator> GetQuals(const Key& key) {        return m_Quals.equal_range(key);    }    pair<const_iterator, const_iterator> GetQuals(const Key& key) const {        return m_Quals.equal_range(key);    }    iterator Erase(iterator it) {        iterator next = it;        if ( next != end() ) {            ++next;            m_Quals.erase(it);        }        return next;    }    void RemoveQuals(const Key& key) {        m_Quals.erase(key);    }    iterator Find(const Key& key) {        return m_Quals.find(key);    }    const_iterator Find(const Key& key) const {        return m_Quals.find(key);    }    size_type Size() const {        return m_Quals.size();    }private:    TQualMMap m_Quals;};/////////////////////////////////////////////////////////////////////////////// concrete qualifiersclass CFlatBoolQVal : public IFlatQVal{public:    CFlatBoolQVal(bool value) : m_Value(value) { }    void Format(TFlatQuals& q, const string& n, CBioseqContext&, TFlags) const        { if (m_Value) { x_AddFQ(q, n, kEmptyStr, CFormatQual::eEmpty); } }private:    bool m_Value;};class CFlatIntQVal : public IFlatQVal{public:    CFlatIntQVal(int value) : m_Value(value) { }    void Format(TFlatQuals& q, const string& n, CBioseqContext&, TFlags) const        { x_AddFQ(q, n, NStr::IntToString(m_Value), CFormatQual::eUnquoted); }private:    int m_Value;};// potential flags://  tilde mode?//  expand SGML entities?// (handle via subclasses?)class CFlatStringQVal : public IFlatQVal{public:    CFlatStringQVal(const string& value, TStyle style = CFormatQual::eQuoted);    CFlatStringQVal(const string& value, const string& pfx, const string& sfx,        TStyle style = CFormatQual::eQuoted);            void Format(TFlatQuals& quals, const string& name, CBioseqContext& ctx,                TFlags flags) const;    const string& GetValue(void) const { return m_Value; }private:    string  m_Value;    TStyle  m_Style;};class CFlatStringListQVal : public IFlatQVal{public:    CFlatStringListQVal(const list<string>& value,        TStyle style = CFormatQual::eQuoted)        :   m_Value(value), m_Style(style) { }    void Format(TFlatQuals& quals, const string& name, CBioseqContext& ctx,                TFlags flags) const;private:    list<string> m_Value;    TStyle       m_Style;};class CFlatCodeBreakQVal : public IFlatQVal{public:    CFlatCodeBreakQVal(const CCdregion::TCode_break value) : m_Value(value) { }    void Format(TFlatQuals& quals, const string& name, CBioseqContext& ctx,                TFlags flags) const;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -