Skip to content

Commit

Permalink
Added contacts spectrum coloring by inter-residue areas.
Browse files Browse the repository at this point in the history
  • Loading branch information
kliment-olechnovic committed Nov 13, 2022
1 parent b95167a commit a9436c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 5 additions & 2 deletions expansion_js/src/duktaper/operators/plot_contacts_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ class PlotContactsMap : public scripting::OperatorBase<PlotContactsMap>
std::vector<std::string> representation_names;
std::string file;
int fixed_plot_size;
bool on_white;

PlotContactsMap() : fixed_plot_size(0)
PlotContactsMap() : fixed_plot_size(0), on_white(false)
{
}

Expand All @@ -43,6 +44,7 @@ class PlotContactsMap : public scripting::OperatorBase<PlotContactsMap>
parameters_for_selecting=scripting::OperatorsUtilities::read_generic_selecting_query(input);
representation_names=input.get_value_vector_or_default<std::string>("rep", std::vector<std::string>());
fixed_plot_size=input.get_value_or_default<int>("fixed-plot-size", 0);
on_white=input.get_flag("on-white");
file=input.get_value<std::string>("file");
scripting::assert_file_name_input(file, false);
}
Expand All @@ -52,6 +54,7 @@ class PlotContactsMap : public scripting::OperatorBase<PlotContactsMap>
scripting::OperatorsUtilities::document_read_generic_selecting_query(doc);
doc.set_option_decription(CDOD("rep", CDOD::DATATYPE_STRING_ARRAY, "representation names", ""));
doc.set_option_decription(CDOD("fixed-plot-size", CDOD::DATATYPE_INT, "fixed side length of output plot", ""));
doc.set_option_decription(CDOD("on-white", CDOD::DATATYPE_BOOL, "flag to use white background", false));
doc.set_option_decription(CDOD("file", CDOD::DATATYPE_STRING, "path to output PNG file"));
}

Expand Down Expand Up @@ -175,7 +178,7 @@ class PlotContactsMap : public scripting::OperatorBase<PlotContactsMap>
}

{
std::vector<unsigned char> png_image_data(plot_size*plot_size*4, 0);
std::vector<unsigned char> png_image_data(plot_size*plot_size*4, (on_white ? 255 : 0));
for(std::size_t i=3;i<png_image_data.size();i+=4)
{
png_image_data[i]=255;
Expand Down
15 changes: 14 additions & 1 deletion src/scripting/operators/spectrum_contacts.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SpectrumContacts : public OperatorBase<SpectrumContacts>

const std::set<std::size_t> representation_ids=data_manager.contacts_representation_descriptor().ids_by_names(representation_names);

if(by!="area" && by!="adjunct" && by!="dist-centers" && by!="dist-balls" && by!="seq-sep" && by!="residue-ids")
if(by!="area" && by!="residue-area" && by!="adjunct" && by!="dist-centers" && by!="dist-balls" && by!="seq-sep" && by!="residue-ids")
{
throw std::runtime_error(std::string("Invalid 'by' value '")+by+"'.");
}
Expand Down Expand Up @@ -144,6 +144,19 @@ class SpectrumContacts : public OperatorBase<SpectrumContacts>
map_of_ids_values[*it]=data_manager.contacts()[*it].value.area;
}
}
else if(by=="residue-area")
{
std::map<common::ChainResidueAtomDescriptorsPair, double> residue_ids_to_values;
for(std::set<std::size_t>::const_iterator it=ids.begin();it!=ids.end();++it)
{
const Contact& contact=data_manager.contacts()[*it];
residue_ids_to_values[common::ConversionOfDescriptors::get_contact_descriptor(data_manager.atoms(), contact).without_some_info(true, true, false, false)]+=contact.value.area;
}
for(std::set<std::size_t>::const_iterator it=ids.begin();it!=ids.end();++it)
{
map_of_ids_values[*it]=residue_ids_to_values[common::ConversionOfDescriptors::get_contact_descriptor(data_manager.atoms(), data_manager.contacts()[*it]).without_some_info(true, true, false, false)];
}
}
else if(by=="dist-centers")
{
for(std::set<std::size_t>::const_iterator it=ids.begin();it!=ids.end();++it)
Expand Down

0 comments on commit a9436c3

Please sign in to comment.