Skip to content

Commit

Permalink
Have mol2WriteAggregateStream return a hash-table
Browse files Browse the repository at this point in the history
of atoms and residues to indexes within Mol2.
  • Loading branch information
meister committed Dec 11, 2024
1 parent 39c771d commit 7ed48dc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/cando/chem/mol2.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ string mol2AtomType(Atom_sp a);

core::HashTable_sp assignSybylTypes(Matter_sp matter);

void mol2WriteAggregateStream( Aggregate_sp agg, std::ostream &out, core::HashTable_sp atom_types );
core::HashTableEql_sp mol2WriteAggregateStream( Aggregate_sp agg, std::ostream &out, core::HashTable_sp atom_types );
void mol2WriteAggregateToFileName( Aggregate_sp a, core::T_sp sFileName, core::HashTable_sp atom_types );

void mol2WriteDumbAggregateToFileName( Aggregate_O& a, core::T_sp sFileName, core::HashTable_sp atom_types );
Expand Down
9 changes: 6 additions & 3 deletions src/chem/candoScript.cc
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ CL_DEFUN core::T_sp chem__save_mol2(Matter_sp matter, core::T_sp destDesig, bool

CL_LAMBDA(matter &optional use-sybyl-types atom-types);
DOCGROUP(cando);
CL_DEFUN std::string chem__aggregate_as_mol2_string(Aggregate_sp matter, bool useSybylTypes, core::T_sp atom_types)
CL_DEFUN core::SimpleBaseString_mv chem__aggregate_as_mol2_string(Aggregate_sp matter, bool useSybylTypes, core::T_sp atom_types)
{
core::HashTable_sp ht;
if (useSybylTypes) {
Expand All @@ -262,8 +262,11 @@ CL_DEFUN std::string chem__aggregate_as_mol2_string(Aggregate_sp matter, bool us
ht = gc::As<core::HashTable_sp>(atom_types);
}
stringstream ss;
mol2WriteAggregateStream(matter,ss,ht);
return ss.str();
core::T_sp res_atom_map = mol2WriteAggregateStream(matter,ss,ht);
if(res_atom_map.nilp()) {
SIMPLE_ERROR("mol2WriteAggregateStream did not return a res-atom-map");
}
return Values(core::SimpleBaseString_O::make(ss.str()),res_atom_map);
}

CL_LAMBDA(matter &optional use-sybyl-types atom-types);
Expand Down
3 changes: 2 additions & 1 deletion src/chem/mol2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ core::HashTable_sp assignSybylTypes( Matter_sp matter) {
return atom_types;
}

void mol2WriteAggregateStream( Aggregate_sp agg, std::ostream &out, core::HashTable_sp atom_types )
core::HashTableEql_sp mol2WriteAggregateStream( Aggregate_sp agg, std::ostream &out, core::HashTable_sp atom_types )
{
Loop loop, lRes;
uint atomCount, bondCount, residueCount;
Expand Down Expand Up @@ -916,6 +916,7 @@ void mol2WriteAggregateStream( Aggregate_sp agg, std::ostream &out, core::HashTa
id++;
}
LOG("Returning" );
return ht;
}


Expand Down
2 changes: 2 additions & 0 deletions src/lisp/cando-widgets/show.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,8 @@
agg))

(defmethod show-on-pane (pane-instance (object chem:aggregate) &rest rest &key &allow-other-keys)
(apply #'ngl-show-on-pane pane-instance object rest)
#+(or)
(let ((rev-molecules nil))
(chem:do-molecules (mol object)
(push mol rev-molecules))
Expand Down

0 comments on commit 7ed48dc

Please sign in to comment.