From e81d914017a424e5e15193ac84194ae4c62e6c12 Mon Sep 17 00:00:00 2001 From: sguionni Date: Thu, 6 Jun 2024 17:26:12 +0200 Subject: [PATCH] Unknown residue names --- .../src/app/component/chemistry/residue.cpp | 37 +++++++++++++++++-- lib/core/include/core/struct/molecule.hpp | 1 + lib/core/src/core/chemdb/residue.cpp | 2 + lib/core/src/core/struct/molecule.cpp | 1 + lib/io/src/io/reader/molecule.cpp | 7 +++- src/main.cpp | 2 - 6 files changed, 44 insertions(+), 6 deletions(-) diff --git a/lib/app/src/app/component/chemistry/residue.cpp b/lib/app/src/app/component/chemistry/residue.cpp index 6c36b7f3e..bb07f61e4 100644 --- a/lib/app/src/app/component/chemistry/residue.cpp +++ b/lib/app/src/app/component/chemistry/residue.cpp @@ -69,10 +69,41 @@ namespace VTX::App::Component::Chemistry const std::string & Residue::getShortName() const { - return ChemDB::Residue::SYMBOL_SHORT_STR[ int( getSymbol() ) ]; + ChemDB::Residue::SYMBOL symbol = getSymbol(); + if ( symbol == ChemDB::Residue::SYMBOL::UNKNOWN ) + { + return _moleculePtr->_moleculeStruct.residueUnknownNames[ _index ]; + } + else + { + return ChemDB::Residue::SYMBOL_SHORT_STR[ int( symbol ) ]; + } + } + const std::string & Residue::getName() const + { + ChemDB::Residue::SYMBOL symbol = getSymbol(); + if ( symbol == ChemDB::Residue::SYMBOL::UNKNOWN ) + { + return _moleculePtr->_moleculeStruct.residueUnknownNames[ _index ]; + } + else + { + return ChemDB::Residue::SYMBOL_STR[ int( symbol ) ]; + } + } + + const std::string & Residue::getLongName() const + { + ChemDB::Residue::SYMBOL symbol = getSymbol(); + if ( symbol == ChemDB::Residue::SYMBOL::UNKNOWN ) + { + return _moleculePtr->_moleculeStruct.residueUnknownNames[ _index ]; + } + else + { + return ChemDB::Residue::SYMBOL_NAME[ int( symbol ) ]; + } } - const std::string & Residue::getName() const { return ChemDB::Residue::SYMBOL_STR[ int( getSymbol() ) ]; } - const std::string & Residue::getLongName() const { return ChemDB::Residue::SYMBOL_NAME[ int( getSymbol() ) ]; } ChemDB::Atom::TYPE Residue::getAtomType() const { diff --git a/lib/core/include/core/struct/molecule.hpp b/lib/core/include/core/struct/molecule.hpp index 75e2ece5e..d8dd25b47 100644 --- a/lib/core/include/core/struct/molecule.hpp +++ b/lib/core/include/core/struct/molecule.hpp @@ -53,6 +53,7 @@ namespace VTX::Core::Struct std::vector residueBondCounts; std::vector residueOriginalIds; std::vector residueSecondaryStructureTypes; + std::vector residueUnknownNames; void initResidues( const size_t p_count ); size_t getResidueCount() const; diff --git a/lib/core/src/core/chemdb/residue.cpp b/lib/core/src/core/chemdb/residue.cpp index f6ddc53ff..ec9847155 100644 --- a/lib/core/src/core/chemdb/residue.cpp +++ b/lib/core/src/core/chemdb/residue.cpp @@ -30,6 +30,7 @@ namespace VTX::Core::ChemDB::Residue return symbol.value_or( SYMBOL::UNKNOWN ); } + const SYMBOL getSymbolFromLongName( const std::string & p_residueName ) { std::string formattedName = std::string( p_residueName.begin(), p_residueName.end() ); @@ -51,6 +52,7 @@ namespace VTX::Core::ChemDB::Residue return SYMBOL::UNKNOWN; } + const SYMBOL getSymbolFromAnyName( const std::string & p_residueName ) { const size_t residueNameSize = p_residueName.size(); diff --git a/lib/core/src/core/struct/molecule.cpp b/lib/core/src/core/struct/molecule.cpp index 3917ef05a..23f0bf360 100644 --- a/lib/core/src/core/struct/molecule.cpp +++ b/lib/core/src/core/struct/molecule.cpp @@ -47,6 +47,7 @@ namespace VTX::Core::Struct residueBondCounts.resize( p_count, 0 ); residueOriginalIds.resize( p_count, 0 ); residueSecondaryStructureTypes.resize( p_count, ChemDB::SecondaryStructure::TYPE::UNKNOWN ); + residueUnknownNames.resize( p_count ); } size_t Molecule::getResidueCount() const { return residueSymbols.size(); } diff --git a/lib/io/src/io/reader/molecule.cpp b/lib/io/src/io/reader/molecule.cpp index 542469e29..4aff8fff1 100644 --- a/lib/io/src/io/reader/molecule.cpp +++ b/lib/io/src/io/reader/molecule.cpp @@ -3,10 +3,10 @@ #include #include #include -#include #include #include #include +#include #include namespace VTX::IO::Reader @@ -100,6 +100,7 @@ namespace VTX::IO::Reader const ChemDB::Residue::SYMBOL residueSymbol = VTX::Core::ChemDB::Residue::getSymbolFromName( residueName ); + // TODO: delete? // int symbolValue; // if ( residueSymbol == ChemDB::Residue::SYMBOL::UNKNOWN ) @@ -129,6 +130,10 @@ namespace VTX::IO::Reader //} p_molecule.residueSymbols[ residueIdx ] = residueSymbol; + if ( residueSymbol == ChemDB::Residue::SYMBOL::UNKNOWN ) + { + p_molecule.residueUnknownNames[ residueIdx ] = residueName; + } const std::string secondaryStructure = p_chemfileStruct.getCurrentResidueStringProperty( "secondary_structure" ); diff --git a/src/main.cpp b/src/main.cpp index 64c184fe2..9a8338f4a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,8 +10,6 @@ #include #ifdef _WIN32 -// #include - extern "C" { __declspec( dllexport ) uint32_t NvOptimusEnablement = 0x00000001;