// Clipper app to calc local map moments /* Copyright 2003-2004 Kevin Cowtan & University of York all rights reserved */ #include #include #include #include int main( int argc, char** argv ) { CCP4Program prog( "cmaplocal", "0.1", "$Date: 2004/05/01" ); // defaults clipper::String ipfile = "NONE"; clipper::String opfile1 = "NONE"; clipper::String opfile2 = "NONE"; double statsrad = -1.0; // command input CCP4CommandInput args( argc, argv, true ); int arg = 0; while ( ++arg < args.size() ) { if ( args[arg] == "-mapin" ) { if ( ++arg < args.size() ) ipfile = args[arg]; } else if ( args[arg] == "-mapout-1" ) { if ( ++arg < args.size() ) opfile1 = args[arg]; } else if ( args[arg] == "-mapout-2" ) { if ( ++arg < args.size() ) opfile2 = args[arg]; } else if ( args[arg] == "-radius" ) { if ( ++arg < args.size() ) statsrad = clipper::String(args[arg]).f(); } else { std::cout << "Unrecognized:\t" << args[arg] << "\n"; args.clear(); } } if ( args.size() <= 1 ) { std::cout << "Usage: cmaplocal\n\t-mapin \n\t-mapout-1 \n\t-mapout-2 \n\t-radius \n"; exit(1); } clipper::CCP4MAPfile file; clipper::Xmap xmap; file.open_read( ipfile ); file.import_xmap( xmap ); file.close_read(); // make squared map clipper::Xmap lmom1( xmap ); clipper::Xmap lmom2( xmap ); for ( clipper::Xmap::Map_reference_index ix = lmom2.first(); !ix.last(); ix.next() ) lmom2[ix] = clipper::Util::sqr( lmom2[ix] ); // now calculate local mom1, local mom1 squared clipper::MapFilterFn_step fn( statsrad ); clipper::MapFilter_fft fltr( fn, 1.0, clipper::MapFilter_fft::Relative ); fltr( lmom1, lmom1 ); fltr( lmom2, lmom2 ); // calculate std deviation for ( clipper::Xmap::Map_reference_index ix = lmom1.first(); !ix.last(); ix.next() ) lmom2[ix] = sqrt( lmom2[ix] - clipper::Util::sqr( lmom1[ix] ) ); // output map file.open_write( opfile1 ); file.export_xmap( lmom1 ); file.close_write(); file.open_write( opfile2 ); file.export_xmap( lmom2 ); file.close_write(); }