Skip to content

Commit

Permalink
- Save residueIndexInOriginalChain and check it for residue search by…
Browse files Browse the repository at this point in the history
… index
  • Loading branch information
Nicolas Dacquay committed Nov 7, 2023
1 parent 5ac1783 commit ac8284e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 26 deletions.
8 changes: 2 additions & 6 deletions lib/app/include/app/component/chemistry/residue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ namespace VTX::App::Component::Chemistry
void setBondCount( const size_t p_bondCount );
ChemDB::Residue::SYMBOL getSymbol() const;
void setSymbol( const ChemDB::Residue::SYMBOL p_symbol );
size_t getIndexInOriginalChain() const;
void setIndexInOriginalChain( const size_t p_index );

const std::string & getShortName() const;
const std::string & getName() const;
Expand All @@ -52,12 +54,6 @@ namespace VTX::App::Component::Chemistry
ChemDB::Atom::TYPE getAtomType() const;
void setAtomType( const ChemDB::Atom::TYPE p_type );

size_t getIndexInOriginalChain() const { return _indexInOriginalChain; };
void setIndexInOriginalChain( const size_t p_indexInOriginalChain )
{
_indexInOriginalChain = p_indexInOriginalChain;
};

const char getInsertionCode() const { return _insertionCode; }
void setInsertionCode( const char p_insertionCode ) { _insertionCode = p_insertionCode; }

Expand Down
9 changes: 9 additions & 0 deletions lib/app/src/app/component/chemistry/residue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ namespace VTX::App::Component::Chemistry
_moleculePtr->_moleculeStruct.residueSymbols[ _index ] = p_symbol;
}

size_t Residue::getIndexInOriginalChain() const
{
return _moleculePtr->_moleculeStruct.residueOriginalIds[ _index ];
}
void Residue::setIndexInOriginalChain( const size_t p_index )
{
_moleculePtr->_moleculeStruct.residueOriginalIds[ _index ] = p_index;
}

const std::string & Residue::getShortName() const
{
return ChemDB::Residue::SYMBOL_SHORT_STR[ int( getSymbol() ) ];
Expand Down
1 change: 1 addition & 0 deletions lib/core/include/core/struct/molecule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace VTX::Core::Struct
std::vector<size_t> residueAtomCounts = std::vector<size_t>();
std::vector<size_t> residueFirstBondIndexes = std::vector<size_t>();
std::vector<size_t> residueBondCounts = std::vector<size_t>();
std::vector<size_t> residueOriginalIds = std::vector<size_t>();

void initResidues( const size_t p_count );
size_t getResidueCount() const;
Expand Down
1 change: 1 addition & 0 deletions lib/core/src/core/struct/molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace VTX::Core::Struct
residueAtomCounts.resize( p_count, 0 );
residueFirstBondIndexes.resize( p_count, INVALID_INDEX );
residueBondCounts.resize( p_count, 0 );
residueOriginalIds.resize( p_count, 0 );
}
size_t Molecule::getResidueCount() const { return residueSymbols.size(); }

Expand Down
34 changes: 22 additions & 12 deletions lib/io/src/io/reader/molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ namespace VTX::IO::Reader
_chemfilesReader = Reader::Chemfiles::readFile( p_path );
_fillStructure( *_chemfilesReader, p_molecule );
}
void Molecule::readBuffer( const std::string & p_buffer,
const FilePath & p_path,
VTX::Core::Struct::Molecule & p_molecule )
void Molecule::readBuffer(
const std::string & p_buffer,
const FilePath & p_path,
VTX::Core::Struct::Molecule & p_molecule
)
{
_chemfilesReader = Reader::Chemfiles::readBuffer( p_buffer, p_path );
_fillStructure( *_chemfilesReader, p_molecule );
Expand Down Expand Up @@ -49,7 +51,8 @@ namespace VTX::IO::Reader

const std::string chainName = p_chemfileStruct.getCurrentChainName();
const std::string chainId = p_chemfileStruct.getCurrentChainID();
std::string residueName = p_chemfileStruct.getCurrentResidueName();
const std::string residueName = p_chemfileStruct.getCurrentResidueName();
const size_t residueId = p_chemfileStruct.getCurrentResidueId();

const VTX::Core::ChemDB::Category::TYPE categoryEnum = _findCategoryType( fileExtension, residueName );

Expand Down Expand Up @@ -92,8 +95,9 @@ namespace VTX::IO::Reader
p_molecule.residueChainIndexes[ residueIdx ] = currentChainIndex;
p_molecule.residueFirstAtomIndexes[ residueIdx ] = ( p_chemfileStruct.getCurrentResidueFirstAtomIndex() );
p_molecule.residueAtomCounts[ residueIdx ] = atomCount;
p_molecule.residueOriginalIds[ residueIdx ] = residueId;

ChemDB::Residue::SYMBOL residueSymbol = VTX::Core::ChemDB::Residue::getSymbolFromName( residueName );
const ChemDB::Residue::SYMBOL residueSymbol = VTX::Core::ChemDB::Residue::getSymbolFromName( residueName );

// int symbolValue;

Expand Down Expand Up @@ -270,7 +274,8 @@ namespace VTX::IO::Reader
void Molecule::_readTrajectoryFrames(
IO::Reader::Chemfiles & p_chemfileStruct,
const std::vector<std::pair<VTX::Core::Struct::Molecule *, size_t>> & p_targets,
const size_t p_trajectoryFrameStart )
const size_t p_trajectoryFrameStart
)
{
// Fill other frames.
Util::Chrono timeReadingFrames;
Expand Down Expand Up @@ -303,7 +308,8 @@ namespace VTX::IO::Reader
if ( frameIdx > 1 && frameIdx % 100 == 0 )
{
VTX_DEBUG(
"Frames from {} to {} read in: {}s.", startingFrame, frameIdx, timeReadingFrames.intervalTime() );
"Frames from {} to {} read in: {}s.", startingFrame, frameIdx, timeReadingFrames.intervalTime()
);
startingFrame = frameIdx;
}
#endif // DEBUG
Expand All @@ -328,8 +334,10 @@ namespace VTX::IO::Reader
}
}

VTX::Core::ChemDB::Category::TYPE Molecule::_findCategoryType( const std::string & p_fileExtension,
const std::string & p_residueSymbol )
VTX::Core::ChemDB::Category::TYPE Molecule::_findCategoryType(
const std::string & p_fileExtension,
const std::string & p_residueSymbol
)
{
VTX::Core::ChemDB::Category::TYPE res;
if ( p_fileExtension == "pdb" || p_fileExtension == "mmcif" || p_fileExtension == "mmtf" )
Expand Down Expand Up @@ -372,9 +380,11 @@ namespace VTX::IO::Reader
const std::string residueSymbol = p_chemfileStruct.getCurrentResidueName();

// Check PSF.
if ( std::find( _configuration->solventResidueSymbols.begin(),
_configuration->solventResidueSymbols.end(),
residueSymbol )
if ( std::find(
_configuration->solventResidueSymbols.begin(),
_configuration->solventResidueSymbols.end(),
residueSymbol
)
!= _configuration->solventResidueSymbols.end() )
{
return ChemDB::Atom::TYPE::SOLVENT;
Expand Down
14 changes: 6 additions & 8 deletions lib/python_binding/test/vtx_api_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ TEST_CASE( "VTX_PYTHON_BINDING - VTX API Selection Tests", "[integration]" )
SelectionUtil::createSelection( allHistidineOn4HHB )
) );

// CHECK( SelectionUtil::checkSelection(
// "test_mol_n_chain_res_1",
// "select( mol_n='4HHB', chain_n='A', res_i=5 )",
// SelectionUtil::createSelection( SelectionUtil::generateMoleculeData( "4HHB", {}, { 3 } ) )
//) ); // NO => Original index in scene not managed
CHECK( SelectionUtil::checkSelection(
"test_mol_n_chain_res_1",
"select( mol_n='4HHB', chain_n='B', res_i=4 )",
SelectionUtil::createSelection( SelectionUtil::generateMoleculeData( "4HHB", {}, { 144 } ) )
) );

// interpretor.runCommand( "select( mol_n='4HHB', atom_t='C')" ); // OK
// interpretor.runCommand( "select( mol_n='4HHB', res_n='HIS', atom_n='O')" ); // OK
Expand All @@ -148,9 +148,7 @@ TEST_CASE( "VTX_PYTHON_BINDING - VTX API Selection Tests", "[integration]" )
) );

CHECK( SelectionUtil::checkSelection(
"test_empty_2",
"select( mol_n='4HHB', res_n='his' )",
SelectionUtil::createSelection( allHistidineOn4HHB )
"test_empty_2", "select( mol_n='4HHB', res_n='his' )", SelectionUtil::createSelection( allHistidineOn4HHB )
) );

// CHECK( SelectionUtil::checkSelection(
Expand Down

0 comments on commit ac8284e

Please sign in to comment.