Skip to content

Commit

Permalink
More clean up of unsigned int comparisons in cootilus
Browse files Browse the repository at this point in the history
  • Loading branch information
pemsley committed Aug 6, 2016
1 parent 3cf3b81 commit 8d691f3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
28 changes: 14 additions & 14 deletions cootilus/nautilus-join.cpp
Expand Up @@ -18,7 +18,7 @@ std::vector<int> NucleicAcidJoin::best_chain( std::vector<Node>& nodes )
// loop starts are now marks as 0
// declare a list of 'dirty' nodes
std::set<int> dirty;
for ( int i = 0; i < node_score.size(); i++ )
for ( unsigned int i = 0; i < node_score.size(); i++ )
if ( node_score[i] == 0.0 ) dirty.insert( i );
// now propogate the values
std::vector<int> bck_ptrs( nodes.size(), -1 );
Expand All @@ -28,7 +28,7 @@ std::vector<int> NucleicAcidJoin::best_chain( std::vector<Node>& nodes )
int node = *iter;
dirty.erase( iter );
// now check the children
for ( int j = 0; j < nodes[node].ptrs.size(); j++ ) {
for ( unsigned int j = 0; j < nodes[node].ptrs.size(); j++ ) {
int next_node = nodes[node].ptrs[j];
// test whether we've found a longer route
float next_score = node_score[node] + nodes[next_node].score;
Expand All @@ -54,7 +54,7 @@ std::vector<int> NucleicAcidJoin::best_chain( std::vector<Node>& nodes )
}
// we've found all the long routes, now find the longest and back-trace it
int node_max = 0;
for ( int i = 1; i < node_score.size(); i++ )
for ( unsigned int i = 1; i < node_score.size(); i++ )
if ( node_score[i] > node_score[node_max] )
node_max = i;
// and back-trace
Expand Down Expand Up @@ -100,7 +100,7 @@ clipper::MiniMol NucleicAcidJoin::join( const clipper::MiniMol& mol )
// make nnb model
clipper::MiniMol molnb( spgr, cell );
clipper::MPolymer chnnb;
for ( int r = 0; r < nas.size(); r++ ) {
for ( unsigned int r = 0; r < nas.size(); r++ ) {
int a = nas[r].lookup( " C1'", clipper::MM::ANY );
clipper::MMonomer mm;
mm.insert( nas[r][a] );
Expand All @@ -111,7 +111,7 @@ clipper::MiniMol NucleicAcidJoin::join( const clipper::MiniMol& mol )

// make list of equivalents
std::vector<int> equivalent( nas.size() );
for ( int r = 0; r < nas.size(); r++ ) equivalent[r] = r;
for ( unsigned int r = 0; r < nas.size(); r++ ) equivalent[r] = r;

// find equivalents
double d2(1.0*1.0), j2(8.0*8.0);
Expand All @@ -125,7 +125,7 @@ clipper::MiniMol NucleicAcidJoin::join( const clipper::MiniMol& mol )
std::vector<clipper::MAtomIndexSymmetry> atoms =
nb( chnnb[r1][0].coord_orth(), 2.0 );
//std::cout << " NB " << r1 << ": ";
for ( int i = 0; i < atoms.size(); i++ ) { // find other equivalent NAs
for ( unsigned int i = 0; i < atoms.size(); i++ ) { // find other equivalent NAs
int r2 = atoms[i].monomer();
//std::cout << r2 << " ";
// if there is a match AND the residues hasn't already been matched
Expand All @@ -152,7 +152,7 @@ clipper::MiniMol NucleicAcidJoin::join( const clipper::MiniMol& mol )
// find links
Node nodenull; nodenull.score = 1.0;
std::vector<Node> joins( nas.size(), nodenull );
for ( int r1 = 0; r1 < nas.size()-1; r1++ ) {
for ( int r1 = 0; r1 < int(nas.size()-1); r1++ ) {
int r2 = r1 + 1;
if ( nas[r2].seqnum() == nas[r1].seqnum()+1 ) {
int a4 = nas[r1].lookup( " C4'", clipper::MM::ANY );
Expand All @@ -164,7 +164,7 @@ clipper::MiniMol NucleicAcidJoin::join( const clipper::MiniMol& mol )
int e1 = equivalent[r1];
int e2 = equivalent[r2];
bool found = false;
for ( int i = 0; i < joins[e1].ptrs.size(); i++ )
for ( unsigned int i = 0; i < joins[e1].ptrs.size(); i++ )
if ( joins[e1].ptrs[i] == e2 ) found = true;
if ( !found ) joins[e1].ptrs.push_back( e2 );
}
Expand All @@ -191,15 +191,15 @@ clipper::MiniMol NucleicAcidJoin::join( const clipper::MiniMol& mol )
// add longest chain to list
chns.push_back( chn );
// remove used fragments
for ( int r = 0; r < chn.size(); r++ )
for ( unsigned int r = 0; r < chn.size(); r++ )
flags[chn[r]] = 0;
// remove links from used fragments
for ( int f = 0; f < joins.size(); f++ )
for ( unsigned int f = 0; f < joins.size(); f++ )
if ( flags[f] == 0 )
joins[f].ptrs.clear();
// and links to used fragments
for ( int f = 0; f < joins.size(); f++ )
for ( int j = joins[f].ptrs.size()-1; j >= 0; j-- )
for ( unsigned int f = 0; f < joins.size(); f++ )
for ( int j = int(joins[f].ptrs.size()-1); j >= 0; j-- )
if ( flags[joins[f].ptrs[j]] == 0 )
joins[f].ptrs.erase( joins[f].ptrs.begin() + j );
}
Expand All @@ -213,11 +213,11 @@ clipper::MiniMol NucleicAcidJoin::join( const clipper::MiniMol& mol )
*/

// build chains from successive NAs, with symmetry shift
for ( int c = 0; c < chns.size(); c++ ) {
for ( unsigned int c = 0; c < chns.size(); c++ ) {
clipper::MPolymer mp;
// set a reference coord to build near
clipper::Coord_orth cref( clipper::Coord_orth::null() );
for ( int r = 0; r < chns[c].size(); r++ ) {
for ( unsigned int r = 0; r < chns[c].size(); r++ ) {
clipper::MMonomer mm = nas[chns[c][r]];
if ( !cref.is_null() ) {
// get nearest symmetry copy
Expand Down
5 changes: 3 additions & 2 deletions cootilus/nautilus-ss-find.cpp
Expand Up @@ -59,7 +59,7 @@ std::vector<SearchResult> SSfind::search( const std::vector<Pair_coord>& target_
for ( unsigned int r = 0; r < ops.size(); r++ ) {
clipper::RTop_orth op = ops[r];
std::vector<std::pair<int,int> > tmp;
for ( int i = 0; i < target_cs.size(); i++ ) {
for ( unsigned int i = 0; i < target_cs.size(); i++ ) {
const clipper::Coord_map c1( grrot*(op*target_cs[i].first ) );
const clipper::Coord_map c2( grrot*(op*target_cs[i].second ) );
tmp.push_back( std::pair<int,int>( mxgr.index(c1.coord_grid()) - i0,
Expand Down Expand Up @@ -92,7 +92,8 @@ std::vector<SearchResult> SSfind::search( const std::vector<Pair_coord>& target_
hi = std::min( hi, mapbox[index0+index_list[i].first ] );
lo = std::max( lo, mapbox[index0+index_list[i].second] );
i++;
if ( !( i < index_list.size() ) ) break;
int idx_ls = index_list.size();
if ( !( i < idx_ls ) ) break;
}
if ( hi - lo > bestlim ) {
bestlim = bestscr = hi - lo;
Expand Down
16 changes: 8 additions & 8 deletions cootilus/nautilus-target.cpp
Expand Up @@ -45,12 +45,12 @@ void NucleicAcidTarget::init_stats( const clipper::Xmap<float>& xmap, const int
double NucleicAcidTarget::radius() const
{
std::vector<clipper::Coord_orth> coords;
for ( int i = 0; i < target_.size(); i++ ) {
for ( unsigned int i = 0; i < target_.size(); i++ ) {
coords.push_back( target_[i].first );
coords.push_back( target_[i].second );
}
double r2 = 0.0;
for ( int a = 0; a < coords.size(); a++ ) {
for ( unsigned int a = 0; a < coords.size(); a++ ) {
double d2 = coords[a].lengthsq();
if ( d2 > r2 ) r2 = d2;
}
Expand All @@ -62,7 +62,7 @@ float NucleicAcidTarget::score_min( const clipper::Xmap<float>& xmap, const clip
{
typedef clipper::Interp_cubic I;
float mn(0.0), mx(0.0);
for ( int i = 0; i < target_.size(); i++ ) {
for ( unsigned int i = 0; i < target_.size(); i++ ) {
mx = std::min(mx,xmap.interp<I>(xmap.coord_map(rtop*target_[i].first )));
mn = std::min(mn,xmap.interp<I>(xmap.coord_map(rtop*target_[i].second)));
}
Expand All @@ -74,7 +74,7 @@ float NucleicAcidTarget::score_sum( const clipper::Xmap<float>& xmap, const clip
{
typedef clipper::Interp_cubic I;
float mn(0.0), mx(0.0);
for ( int i = 0; i < target_.size(); i++ ) {
for ( unsigned int i = 0; i < target_.size(); i++ ) {
mx += xmap.interp<I>(xmap.coord_map(rtop*target_[i].first ));
mn += xmap.interp<I>(xmap.coord_map(rtop*target_[i].second));
}
Expand Down Expand Up @@ -449,13 +449,13 @@ const clipper::MiniMol NucleicAcidTargets::find( const clipper::Xmap<float>& xma

// filter lists on translation
std::vector<SearchResult> filter_s, filter_p;
for ( int i = 0; i < found_s.size(); i++ ) {
for ( unsigned int i = 0; i < found_s.size(); i++ ) {
int it = found_s[i].trn;
clipper::Coord_orth trn( xmap.coord_orth( grid.deindex(it).coord_map() ) );
std::vector<clipper::MAtomIndexSymmetry> atoms = nb( trn, 4.0 );
if ( atoms.size() == 0 ) filter_s.push_back( found_s[i] );
}
for ( int i = 0; i < found_p.size(); i++ ) {
for ( unsigned int i = 0; i < found_p.size(); i++ ) {
int it = found_p[i].trn;
clipper::Coord_orth trn( xmap.coord_orth( grid.deindex(it).coord_map() ) );
std::vector<clipper::MAtomIndexSymmetry> atoms = nb( trn, 4.0 );
Expand Down Expand Up @@ -574,7 +574,7 @@ const clipper::MiniMol NucleicAcidTargets::prune( const clipper::MiniMol& mol )
for ( int a1 = 0; a1 < mol_nb[c1][r1].size(); a1++ ) {
const clipper::Coord_orth co = mol_nb[c1][r1][a1].coord_orth();
std::vector<clipper::MAtomIndexSymmetry> atoms = nb( co, 2.0 );
for ( int i = 0; i < atoms.size(); i++ ) {
for ( unsigned int i = 0; i < atoms.size(); i++ ) {
int c2 = atoms[i].polymer();
int r2 = atoms[i].monomer();
if ( !mol_nb[c2].exists_property( "NON-NA" ) ) { // clash with NA
Expand Down Expand Up @@ -715,7 +715,7 @@ const clipper::MiniMol NucleicAcidTargets::rebuild_bases( const clipper::Xmap<fl
if ( test ) {
const clipper::Coord_orth co = mol_new[c1][r1][a1].coord_orth();
std::vector<clipper::MAtomIndexSymmetry> atoms = nb( co, 2.0 );
for ( int i = 0; i < atoms.size(); i++ ) {
for ( unsigned int i = 0; i < atoms.size(); i++ ) {
int c2 = atoms[i].polymer();
int r2 = atoms[i].monomer();
if ( c1 != c2 || r1 != r2 ) clash = true;
Expand Down
2 changes: 1 addition & 1 deletion cootilus/nautilus-tools.cpp
Expand Up @@ -67,7 +67,7 @@ clipper::MiniMol NucleicAcidTools::flag_chains( const clipper::MiniMol& mol )
if ( flag[r] == 0 && flag[r-1] == -1 ) flag[r] = -1;
for ( int r = int(flag.size()-2); r > 0; r-- )
if ( flag[r] == 0 && flag[r+1] == -1 ) flag[r] = -1;
for ( unsigned int r = 0; r < mol_new[c].size(); r++ )
for ( int r = 0; r < mol_new[c].size(); r++ )
if ( flag[r] == -1 ) mol_new[c][r].set_type( "?" );
}
}
Expand Down

0 comments on commit 8d691f3

Please sign in to comment.