/* $Id: OrgMod.hpp 692747 2025-01-28 14:23:39Z ivanov $
 * ===========================================================================
 *
 *                            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.
 *
 * ===========================================================================
 *
 */

/// @OrgMod.hpp
/// User-defined methods of the data storage class.
///
/// This file was originally generated by application DATATOOL
/// using the following specifications:
/// 'seqfeat.asn'.
///
/// New methods or data members can be added to it if needed.
/// See also: OrgMod_.hpp


#ifndef OBJECTS_SEQFEAT_ORGMOD_HPP
#define OBJECTS_SEQFEAT_ORGMOD_HPP


// generated includes
#include <objects/seqfeat/OrgMod_.hpp>

// generated classes

BEGIN_NCBI_SCOPE

BEGIN_objects_SCOPE // namespace ncbi::objects::

/////////////////////////////////////////////////////////////////////////////
class NCBI_SEQFEAT_EXPORT COrgMod : public COrgMod_Base
{
    typedef COrgMod_Base Tparent;
public:
    // constructor
    COrgMod(void);
    COrgMod(TSubtype subtype, const TSubname& subname);
    COrgMod(const string& subtype, const TSubname& subname);
    // destructor
    ~COrgMod(void);

    // Find the enumerated subtype value.
    // does case-insesitive search and '_' are converted to '-'.
    // Throws an exception on failure.
    enum EVocabulary {
        eVocabulary_raw, // per ASN.1, except eSubtype_other <-> "note"
        eVocabulary_insdc // per GB/DDBJ/EMBL qualifier names
    };
    static TSubtype GetSubtypeValue(const string& str,
                                    EVocabulary vocabulary = eVocabulary_raw);
    static string GetSubtypeName(TSubtype stype,
                                 EVocabulary vocabulary = eVocabulary_raw);

    // returns false if GetSubtypeName is expected to throw an exception. True otherwise.
    static bool IsValidSubtypeName(const string& str,
                                   EVocabulary vocabulary = eVocabulary_raw);

    static bool IsDiscouraged(const TSubtype stype, bool indexer=false);
    static bool IsMultipleValuesAllowed(TSubtype);

    /// This indicates if the given Org-mod subtype is supposed to hold an
    /// institution code (Example: "ATCC:27305")
    static bool HoldsInstitutionCode(const TSubtype stype);

    static bool ParseStructuredVoucher(const string& str, string& inst, string& coll, string& id);

    static bool IsInstitutionCodeValid(const string& inst_coll, string &voucher_type, bool& is_miscapitalized, string& correct_cap, bool& needs_country, bool& erroneous_country);
    static string IsCultureCollectionValid(const string& culture_collection);
    static string IsSpecimenVoucherValid(const string& specimen_voucher);
    static string IsBiomaterialValid(const string& biomaterial);
    static string IsStructuredVoucherValid(const string& val, const string& voucher_type);
    static string MakeStructuredVoucher(const string& inst, const string& coll, const string& id);
    static bool FixStructuredVoucher(string& val, const string& voucher_type);
    static bool AddStructureToVoucher(string& val, const string& voucher_type);
    static bool RescueInstFromParentheses(string& val, const string& voucher_type);
    static string CheckMultipleVouchers(const vector<string>&);

    //e.g. "DMNS:Bird" to "Denver Museum of Nature and Science, Ornithology Collections"
    // returns empty string if not found
    static const string &GetInstitutionFullName( const string &short_name );
    static const string &GetInstitutionShortName( const string &full_name );

    static string FixStrain( const string& strain);
    static bool FuzzyStrainMatch( const string& strain1, const string& strain2 );
    static bool IsStrainValid(const string& strain);
    static bool IsIsolateValid(const string& isolate);

    static string FixHost(const string& value);
    static string FixHostCapitalization(const string& value);
    static string FixCapitalization(TSubtype subtype, const string& value);
    void FixCapitalization();

    static string AutoFix(TSubtype subtype, const string& value);
    void AutoFix();

    static bool IsDeprecated(TSubtype subtype);
    bool IsDeprecated() const;

    // Remove "subsp. " and "serovar " from start of strain
    // Remove "subsp. " and "serovar " from start of serovar
    // Remove "subsp. " from start of sub-species qualifier
    bool RemoveAbbreviation();

    static bool IsUnexpectedViralOrgModQualifier(TSubtype subtype);
    bool IsUnexpectedViralOrgModQualifier() const;

    // for type material
    static bool IsValidTypeMaterial(const string& type_material);
    // note that the INSDC definition is currently lagging behind what is considered
    // valid for taxonomy
    static bool IsINSDCValidTypeMaterial(const string& type_material);

    typedef map<string, string, PNocase> TInstitutionCodeMap;

    // Allows instant transition when quarantine period ends.
    static bool NCBI_ValidateForMultipleIsolates(void);

private:
    // Prohibit copy constructor and assignment operator
    COrgMod(const COrgMod& value);
    COrgMod& operator=(const COrgMod& value);

    static TInstitutionCodeMap::iterator FindInstitutionCode(const string& inst_coll, TInstitutionCodeMap& code_map,
        bool& is_miscapitalized, string& correct_cap, bool& needs_country, bool& erroneous_country);

};

/////////////////// COrgMod inline methods

// constructor
inline
COrgMod::COrgMod(void)
{
}

inline
COrgMod::COrgMod(TSubtype subtype, const TSubname& subname)
{
    SetSubtype(subtype);
    SetSubname(subname);
}


inline
COrgMod::COrgMod(const string& subtype, const TSubname& subname)
{
    SetSubtype(GetSubtypeValue(subtype));
    SetSubname(subname);
}

/////////////////// end of COrgMod inline methods


END_objects_SCOPE // namespace ncbi::objects::

END_NCBI_SCOPE

#endif // OBJECTS_SEQFEAT_ORGMOD_HPP
/* Original file checksum: lines: 94, chars: 2521, CRC32: 79cf88de */
