Skip to content
Snippets Groups Projects
Commit 6a018869 authored by Rafal Gumienny's avatar Rafal Gumienny
Browse files

feat: SCHWED-3126 Implementation of basic Molck function

parent 53b82b75
No related branches found
No related tags found
No related merge requests found
// #include <unistd.h>
// #include <boost/program_options.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/convenience.hpp>
#include <ost/base.hh>
#include <ost/boost_filesystem_helper.hh>
// #include <ost/platform.hh>
#include <ost/conop/model_check.hh>
#include <ost/conop/conop.hh>
#include <ost/conop/amino_acids.hh>
#include <ost/io/mol/pdb_reader.hh>
// #include <ost/io/mol/pdb_writer.hh>
#include <ost/io/mol/mmcif_reader.hh>
// #include <ost/io/io_exception.hh>
#include <ost/conop/nonstandard.hh>
#include <ost/mol/alg/molck.hh>
// #if defined(__APPLE__)
// #include <mach-o/dyld.h>
// #endif
// using namespace ost;
using namespace ost::conop;
using namespace ost::mol;
using namespace ost::io;
// namespace po=boost::program_options;
namespace fs=boost::filesystem;
EntityHandle ost::mol::alg::molck::load_x(const String& file, const IOProfile& profile)
{
try {
......@@ -135,7 +127,8 @@ EntityHandle ost::mol::alg::molck::MapNonStandardResidues(EntityHandle& ent, Com
return new_ent;
}
void ost::mol::alg::molck::RemoveAtoms(EntityHandle& ent,
void ost::mol::alg::molck::RemoveAtoms(
EntityHandle& ent,
CompoundLibPtr lib,
bool rm_unk_atoms,
bool rm_non_std,
......@@ -231,4 +224,53 @@ void ost::mol::alg::molck::CleanUpElementColumn(EntityHandle& ent, CompoundLibPt
}
}
}
}
\ No newline at end of file
}
void ost::mol::alg::molck::Molck(
ost::mol::EntityHandle& ent,
ost::conop::CompoundLibPtr lib,
const ost::mol::alg::molck::MolckSettings& settings=ost::mol::alg::molck::MolckSettings()){
if (settings.map_nonstd_res) {
ent = ost::mol::alg::molck::MapNonStandardResidues(ent, lib);
}
ost::mol::alg::molck::RemoveAtoms(ent,
lib,
settings.rm_unk_atoms,
settings.rm_non_std,
settings.rm_hyd_atoms,
settings.rm_oxt_atoms,
settings.rm_zero_occ_atoms,
settings.colored);
if (settings.assign_elem) {
ost::mol::alg::molck::CleanUpElementColumn(ent, lib);
}
}
// ost::mol::EntityHandle ost::mol::alg::molck::Molck(
// String& file,
// ost::conop::CompoundLibPtr lib,
// const ost::mol::alg::molck::MolckSettings& settings=ost::mol::alg::molck::MolckSettings()){
// IOProfile prof;
// prof.fault_tolerant=true;
// EntityHandle ent = ost::mol::alg::molck::load_x(file, prof);
// if (!ent.IsValid()) {
// throw std::runtime_error("Entity is invalid!");
// }
// if (settings.map_nonstd_res) {
// ent = ost::mol::alg::molck::MapNonStandardResidues(ent, lib);
// }
// ost::mol::alg::molck::RemoveAtoms(ent,
// lib,
// settings.rm_unk_atoms,
// settings.rm_non_std,
// settings.rm_hyd_atoms,
// settings.rm_oxt_atoms,
// settings.rm_zero_occ_atoms,
// settings.colored);
// if (settings.assign_elem) {
// ost::mol::alg::molck::CleanUpElementColumn(ent, lib);
// }
// return ent;
// }
\ No newline at end of file
......@@ -5,9 +5,35 @@
namespace ost { namespace mol{ namespace alg{ namespace molck {
struct MolckSettings;
struct MolckSettings{
bool rm_unk_atoms;
bool rm_non_std;
bool rm_hyd_atoms;
bool rm_oxt_atoms;
bool rm_zero_occ_atoms;
bool colored;
bool map_nonstd_res;
bool assign_elem;
MolckSettings(): rm_unk_atoms(false), // Remove unknown and atoms not following the nomenclature
rm_non_std(false), // Remove all residues not one of the 20 standard amino acids
rm_hyd_atoms(true), // Remove hydrogen atoms
rm_oxt_atoms(false), // Remove terminal oxygens
rm_zero_occ_atoms(false), // Remove atoms with zero occupancy
colored(false), // Whether the output should be colored
map_nonstd_res(true), // Map non standard residues back to standard ones (e.g.: MSE->MET,SEP->SER,etc.)
assign_elem(true){} // Clean up element column
};
ost::mol::EntityHandle load_x(const String& file, const ost::io::IOProfile& profile);
ost::conop::CompoundLibPtr load_compound_lib(const String& custom_path);
ost::mol::EntityHandle MapNonStandardResidues(ost::mol::EntityHandle& ent, ost::conop::CompoundLibPtr lib);
void RemoveAtoms(ost::mol::EntityHandle& ent,
ost::conop::CompoundLibPtr lib,
bool rm_unk_atoms,
......@@ -16,19 +42,13 @@ void RemoveAtoms(ost::mol::EntityHandle& ent,
bool rm_oxt_atoms,
bool rm_zero_occ_atoms,
bool colored=true);
void CleanUpElementColumn(ost::mol::EntityHandle& ent, ost::conop::CompoundLibPtr lib);
struct MolckSettings{
String rm;
String color;
bool map_nonstd_res;
bool assign_elem;
void Molck(ost::mol::EntityHandle& ent, ost::conop::CompoundLibPtr lib, const MolckSettings& settings);
// void Molck(ost::mol::EntityHandle& ent, String& custom_path, const MolckSettings& settings);
// ost::mol::EntityHandle Molck(String& file, ost::conop::CompoundLibPtr lib, const MolckSettings& settings);
// ost::mol::EntityHandle Molck(String& file, String& custom_path, const MolckSettings& settings);
MolckSettings(): rm("hyd"), // atoms to be removed
color("auto"), // whether the output should be colored
map_nonstd_res(true), // map non standard residues back to standard ones (e.g.: MSE->MET,SEP->SER,etc.)
assign_elem(true){} // clean up element column
};
}}}} // namespace
......@@ -5,14 +5,9 @@
#include <ost/base.hh>
#include <ost/boost_filesystem_helper.hh>
#include <ost/platform.hh>
#include <ost/conop/model_check.hh>
#include <ost/conop/conop.hh>
#include <ost/conop/amino_acids.hh>
#include <ost/io/mol/pdb_reader.hh>
#include <ost/io/mol/pdb_writer.hh>
#include <ost/io/mol/mmcif_reader.hh>
#include <ost/io/io_exception.hh>
#include <ost/conop/nonstandard.hh>
#include <ost/mol/alg/molck.hh>
#if defined(__APPLE__)
#include <mach-o/dyld.h>
......@@ -63,19 +58,12 @@ int main(int argc, char *argv[])
}
IOProfile prof;
prof.fault_tolerant=true;
MolckSettings settings;
String rm;
String color;
bool colored = false;
bool rm_unk_atoms=false;
bool rm_hyd_atoms=false;
bool rm_non_std=false;
bool rm_oxt_atoms=false;
bool rm_zero_occ_atoms=false;
bool write_to_stdout = false;
bool write_to_file = false;
bool map_nonstd_res = false;
bool assign_elem = false;
String output_blueprint_string;
String custom_path="";
......@@ -123,24 +111,24 @@ int main(int argc, char *argv[])
output_blueprint_string = vm["out"].as<String>();
}
if (vm.count("map-nonstd")) {
map_nonstd_res = true;
settings.map_nonstd_res = true;
}
if (vm.count("fix-ele")) {
assign_elem = true;
settings.assign_elem = true;
}
std::vector<StringRef> rms=StringRef(rm.c_str(), rm.size()).split(',');
for (size_t i=0; i<rms.size(); ++i) {
if (rms[i] == StringRef("unk", 3)) {
rm_unk_atoms = true;
settings.rm_unk_atoms = true;
} else if (rms[i] == StringRef("nonstd", 6)) {
rm_non_std = true;
settings.rm_non_std = true;
} else if (rms[i] == StringRef("hyd", 3)) {
rm_hyd_atoms = true;
settings.rm_hyd_atoms = true;
} else if (rms[i] == StringRef("oxt", 3)) {
rm_oxt_atoms = true;
settings.rm_oxt_atoms = true;
} else if (rms[i] == StringRef("zeroocc", 7)) {
rm_zero_occ_atoms = true;
settings.rm_zero_occ_atoms = true;
} else {
std::cerr << "unknown value to remove '" << rms[i] << "'" << std::endl;
usage();
......@@ -148,11 +136,11 @@ int main(int argc, char *argv[])
}
}
if (color=="auto") {
colored = isatty(STDERR_FILENO);
settings.colored = isatty(STDERR_FILENO);
} else if (color == "on" || color == "1" || color == "yes") {
colored = true;
settings.colored = true;
} else if (color == "off" || color == "0" || color == "no") {
colored = false;
settings.colored = false;
} else {
usage();
exit(-1);
......@@ -163,22 +151,8 @@ int main(int argc, char *argv[])
if (!ent.IsValid()) {
continue;
}
if (map_nonstd_res) {
ent = MapNonStandardResidues(ent, lib);
}
RemoveAtoms(ent,
lib,
rm_unk_atoms,
rm_non_std,
rm_hyd_atoms,
rm_oxt_atoms,
rm_zero_occ_atoms,
colored);
if (assign_elem) {
CleanUpElementColumn(ent, lib);
}
Molck(ent, lib, settings);
if (write_to_stdout) {
PDBWriter writer(std::cout, prof);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment