; SEPARATES GOOD PARTICLES BY DEFOCUS-GROUP ; ----------------- Parameters ----------------- x58 = 0.00 ; fraction of particles to omit from each defocus-group x56 = 2 ; prints progress message to screen every (x56)th defocus-group ; ------------------- Inputs ------------------- fr l [combined_good_list]combinedgood ; combined list of good particles ; VIEW_SLICE PARTICLE GROUP_SLICE CCROT MIRROR GROUP fr l [df_group_list]sel_group ; list of defocus-group numbers fr l [df_unpicked_list]stack2particle ; total-particle list prefix, for each defocus-group ; KEY:DF_SLICE / PARTICLE ; used ; ------------------- Outputs ------------------- fr l [good_dir]df ; directory template where defocus-group lists will go fr l [df_good_list]goodparticles ; good-particle list, for each defocus-group, in GOOD_DIR ; GROUP_SLICE PARTICLE CCROT fr l [defgrps_lim]sel_group_cclim ; Defocus groups selection file fr l [defgrps_lim_sorted]sel_group_cclim_sorted ; Defocus groups selection file fr l [df_stats_doc]summary-goodparticles ; stats document showing number of particles ; -------------- END BATCH HEADER -------------- vm echo "Making good-particle list for each defocus-group"; date ; clean up de [defgrps_lim] SD / DF_GROUP NUMPARTS AVG_DEFOCUS [defgrps_lim] de [defgrps_lim_sorted] SD / DF_GROUP NUMPARTS AVG_DEFOCUS [defgrps_lim_sorted] de [df_stats_doc] SD / KEPT TOTAL FRACTION [df_stats_doc] ; get number of good particles (x83) ud n,x83 [combined_good_list] md vb off x63=0 ; initialize particle-counter ; get number of defocus-groups (x76) ud n,x76 [df_group_list] ; loop through defocus-groups do lb7 x70=1,x76 ; get current defocus-group number (x71), defocus (x73) ud ic,x70,x71,x72,x73 [df_group_list] vm echo "if(! -d [good_dir]{***x71}) mkdir -p [good_dir]{***x71}"|csh if (int(x70/x56).eq.x70/x56) then vm echo "Working on defocus-group #{***x70} out of {***x76}" endif ; for DF_UNPICKED_LIST, move particle# to second column from first doc key [df_unpicked_list]{***x71} [df_unpicked_list]{***x71}_rekey ; find union of negative-particle list and combined-good list doc and [combined_good_list] [df_unpicked_list]{***x71}_rekey [good_dir]{***x71}/[df_good_list]_unsort (2) ; column to check: particle# ; trap for empty defocus groups ud n,x74 [good_dir]{***x71}/[df_good_list]_unsort if(x74.ge.1) then ; sort by CCC doc sort [good_dir]{***x71}/[df_good_list]_unsort [good_dir]{***x71}/[df_good_list]_byccc (4) ; column# to sort: CCC Y ; renumber? ; get number of particles (x59) from defocus-group ud n,x59 [good_dir]{***x71}/[df_good_list]_byccc ; calculate #particles to omit x57=x59*x58 ; x59==total particles, x58==fraction ; SAVE PARTICLES WITH HIGHEST CCC ; loop through particles do lb5 x50=1,x59 ; get particle# (x52), group-slice# (x53), CCROT (x54) ud ic,x50,x51,x52,x53,x54 [good_dir]{***x71}/[df_good_list]_byccc if(x50.gt.x57) then sd x50,x53,x52,x54 [good_dir]{***x71}/[df_good_list]_truncated ; x53==group-slice#, x52==particle#, x54==CCROT endif lb5 ; end particle-loop ; close documents ud ice [good_dir]{***x71}/[df_good_list]_byccc sd e [good_dir]{***x71}/[df_good_list]_truncated ; sort by particle# doc sort [good_dir]{***x71}/[df_good_list]_truncated [good_dir]{***x71}/[df_good_list] (1) ; column# to sort: particle# Y ; renumber? SD / GROUPSLICE PARTICLE CC_ROT [good_dir]{***x71}/[df_good_list] sd e [good_dir]{***x71}/[df_good_list] ud n,x54 [good_dir]{***x71}/[df_good_list] x55=x54/x59 ; fraction kept else vm echo "No particles kept in group #{***x71}" x59 = 0 ; total #particles x54 = 0 ; #kept x55 = 0 ; fraction kept endif ; write to stats doc sd x71,x54,x59,x55 [df_stats_doc] ; x71==defocus-group#, x54==#kept, x59==total, x55==fraction ; update sel_groups sd x71,x71,x54,x73 [defgrps_lim] ; x71==group#, x54==#particles, x73==defocus) ; clean up temporary files de [df_unpicked_list]{***x71}_rekey de [good_dir]{***x71}/[df_good_list]_unsort de [good_dir]{***x71}/[df_good_list]_byccc de [good_dir]{***x71}/[df_good_list]_truncated x63=x63+x54 ; increment good-particle counter lb7 ; end group-loop ; close documents sd e [defgrps_lim] ud ice [df_group_list] SD / BEFORECUTOFF AFTER_CUTOFF [df_stats_doc] x67 = -x76 sd x67, x83,x63 [df_stats_doc] sd e [df_stats_doc] vm m echo ; echo "Total particles in selection docs (before removing fraction): {******x83}" ; echo "Total particles sorted by defocus-group (after removal): {******x63}" . ; SORT SEL_GROUP_CCLIM BY #PARTICLES de [defgrps_lim_sorted]_rev ; sort by #particles doc sort [defgrps_lim] [defgrps_lim_sorted]_rev (2) ; column# to sort: #particles Y ; renumber? ; loop though defocus-groups (max: x76) do lb6 x50=1,x76 ; count from end x51=x76-x50+1 ; read group# (x51), #particles (x52), defocus (x53) ud ic,x51,x51,x52,x53 [defgrps_lim_sorted]_rev ; write to sorted doc sd x50,x51,x52,x53 [defgrps_lim_sorted] lb6 ; end group-loop ; clean up sd e [defgrps_lim_sorted] ud ice [defgrps_lim_sorted]_rev de [defgrps_lim_sorted]_rev vm echo "Done"; date en d ; Modified 2010-01-07 ; 2009-06-15 (trs) -- checks for empty defocus groups ; 2008-01-31 (trs) -- using stack2particle as input instead of sel_particles ; 2007-08-21 (trs,tsb) -- reflects changes to input doc file sel_particles ; 2007-03-27 (trs) -- reflects changes to input doc file sel_particles ; 2007-01-30 (trs,djt) -- bug fix: used label LB5 twice ; 2007-01-30 (trs) -- updated for changes to default batch files ; 2007-01-30 (trs) -- added outputs sel_group_cclim & sel_group_cclim_sorted ; 2007-01-30 (trs) -- creation of odd & even files moved to bps-by-df ; 2006-05-12 (trs,rag) -- bug fix: VM M command lacked ending period ; 2006-03-02 (trs,pp) -- bug fix: got length of particle list from unrenumbered file ; 2005-05-19 (trs) -- removes worst particles from each defocus-group ; 2005-05-19 (trs) -- moved combined good-particle list and histogram elsewhere ; 2004-12-30 (trs) -- creates order_defocus