1 /* $Id: write_util.hpp 637282 2021-09-09 19:27:15Z ivanov $ 2 * =========================================================================== 3 * 4 * PUBLIC DOMAIN NOTICE 5 * National Center for Biotechnology Information 6 * 7 * This software/database is a "United States Government Work" under the 8 * terms of the United States Copyright Act. It was written as part of 9 * the author's official duties as a United States Government employee and 10 * thus cannot be copyrighted. This software/database is freely available 11 * to the public for use. The National Library of Medicine and the U.S. 12 * Government have not placed any restriction on its use or reproduction. 13 * 14 * Although all reasonable efforts have been taken to ensure the accuracy 15 * and reliability of the software and data, the NLM and the U.S. 16 * Government do not and cannot warrant the performance or results that 17 * may be obtained by using this software or data. The NLM and the U.S. 18 * Government disclaim all warranties, express or implied, including 19 * warranties of performance, merchantability or fitness for any particular 20 * purpose. 21 * 22 * Please cite the author in any work or product based on this material. 23 * 24 * =========================================================================== 25 * 26 * Authors: Frank Ludwig 27 * 28 * File Description: Common writer functions 29 * 30 */ 31 32 #ifndef OBJTOOLS_READERS___WRITE_UTIL__HPP 33 #define OBJTOOLS_READERS___WRITE_UTIL__HPP 34 35 #include <corelib/ncbistd.hpp> 36 #include <objmgr/object_manager.hpp> 37 #include <objmgr/scope.hpp> 38 #include <objmgr/util/feature.hpp> 39 40 #include <objects/seq/Seq_annot.hpp> 41 #include <objects/seq/Annotdesc.hpp> 42 #include <objects/seqfeat/OrgMod.hpp> 43 #include <objects/seqfeat/SubSource.hpp> 44 #include <objects/seqfeat/Code_break.hpp> 45 #include <objects/seqfeat/Trna_ext.hpp> 46 47 BEGIN_NCBI_SCOPE 48 BEGIN_objects_SCOPE 49 50 // ============================================================================ 51 class NCBI_XOBJWRITE_EXPORT CWriteUtil 52 // ============================================================================ 53 { 54 public: 55 static CRef<CUser_object> GetDescriptor( 56 const CSeq_annot& annot, 57 const string& ); 58 59 static bool GetGenomeString( 60 const CBioSource&, 61 string& ); 62 63 static bool GetOrgModSubType( 64 const COrgMod&, 65 string&, 66 string& ); 67 68 static bool GetSubSourceSubType( 69 const CSubSource&, 70 string&, 71 string& ); 72 73 static bool GetBiomol( 74 CBioseq_Handle, 75 string& ); 76 77 static bool GetIdType( 78 CBioseq_Handle, 79 string& ); 80 81 static bool GetIdType( 82 const CSeq_id&, 83 string& ); 84 85 static bool GetAaName( 86 const CCode_break&, 87 string& ); 88 89 static bool GetCodeBreak( 90 const CCode_break&, 91 string& ); 92 93 static bool GetGeneRefGene( 94 const CGene_ref&, 95 string& ); 96 97 static bool GetTrnaProductName( 98 const CTrna_ext&, 99 string& ); 100 101 static bool GetBestId( 102 CSeq_id_Handle, 103 CScope&, 104 string&); 105 106 static bool GetBestId( 107 const CMappedFeat&, 108 string&); 109 110 static bool GetTrnaCodons( 111 const CTrna_ext&, 112 string& ); 113 114 static bool GetTrnaAntiCodon( 115 const CTrna_ext&, 116 string& ); 117 118 static bool GetDbTag( 119 const CDbtag&, 120 string& ); 121 122 static bool IsLocationOrdered( 123 const CSeq_loc& ); 124 125 static bool IsSequenceCircular( 126 CBioseq_Handle ); 127 128 static string UrlEncode( 129 const string& ); 130 131 static bool NeedsQuoting( 132 const string& ); 133 134 static void ChangeToPackedInt( 135 CSeq_loc& loc); 136 137 static bool GetQualifier( 138 CMappedFeat mf, 139 const string& key, 140 string& value); 141 142 static CConstRef<CUser_object> GetUserObjectByType( 143 const CUser_object& uo, 144 const string& strType); 145 146 static CConstRef<CUser_object> GetUserObjectByType( 147 const list<CRef<CUser_object > >& uos, 148 const string& strType); 149 150 static CConstRef<CUser_object> GetModelEvidence( 151 CMappedFeat); 152 153 static bool GetStringForModelEvidence( 154 CMappedFeat mf, 155 string& mestr); 156 157 static bool GetStringForGoMarkup( 158 const vector<CRef<CUser_field > >& fields, 159 string& goMarkup, 160 bool relaxed = false); 161 162 static bool GetStringsForGoMarkup( 163 const vector<CRef<CUser_field > >& fields, 164 vector<string>& goMarkup, 165 bool relaxed = false); 166 167 static bool GetListOfGoIds( 168 const vector<CRef<CUser_field > >& fields, 169 list<std::string>& goIds, 170 bool relaxed = false); 171 172 static bool IsThreeFeatFormat( 173 const CSeq_annot&); 174 175 static bool GetThreeFeatType( 176 const CSeq_feat&, 177 string&); 178 179 static bool GetThreeFeatScore( 180 const CSeq_feat&, 181 int&); 182 183 static bool GetThreeFeatRgb( 184 const CSeq_feat&, 185 string&); 186 187 static bool CompareLocations( 188 const CMappedFeat& lhs, 189 const CMappedFeat& rhs); 190 191 static string GetStringId( 192 const CSeq_loc& loc); 193 194 static bool IsNucleotideSequence( 195 CBioseq_Handle); 196 197 static bool IsProteinSequence( 198 CBioseq_Handle); 199 200 static bool IsTransspliced( 201 const CSeq_feat& feature); 202 203 static bool IsTransspliced( 204 const CMappedFeat& mf); 205 206 static bool GetTranssplicedEndpoints( 207 const CSeq_loc& loc, 208 unsigned int& inPoint, 209 unsigned int& outPoint); 210 211 static ENa_strand GetEffectiveStrand( 212 const CSeq_interval&); 213 }; 214 215 END_objects_SCOPE 216 END_NCBI_SCOPE 217 218 #endif // OBJTOOLS_WRITERS___WRITE_UTIL__HPP 219