; MAKE SELECTION DOC FILES FOR EACH REFERENCE VIEW, ; COMBINED FOR ALL DEFOCUS-GROUPS ; ; REQUIRES reversedoc_7col.spi ; ------------------ Parameters ------------------ x76 = 10 ; prints progress message every (x76)th defocus group x56 = 20 ; prints progress message every (x56)th reference view x83 = 83 ; number of reference-projections ; ------------------ Input files ---------------- FR L [df_group_list]sel_group ; list of defocus groups FR L [group2micslice]../Alignment/sel_particles_*** ; slice-to-particle lookup-table, for each group ; DF_SLICE MICSLICE DF_GROUP MICROGRAPH ; used used used FR L [mic2global]../Particles/coords/mic2global**** ; micrograph-particle lookup-table, for each micrograph FR L [align_doc]../Alignment/align_01_*** ; total-particle alignment-doc, for each defocus group ; ------------------ Output files ---------------- FR L [ref_view_list]../Alignment/projlist ; list of reference views FR L [stack2particle_lut]stack2particle*** ; stack-to-particle lookup table, for each defocus-group ; / PARTICLE MICROGRAPH MIC_SLICE GROUP_SLICE FR L [df_dir]df{***x77} ; defocus-group directory prefix FR L [view_dir]select ; output directories, one for each group and one combined fr g [prj_dir][view_dir]/prj{***x80} ; output subdirectory prefix, for each reference-view FR L [by_view_list]sel*** ; by-view list, in DF_DIR/VIEW_DIR and combined in VIEW_DIR ; / VIEW_SLICE GLOBPARTICLE DF_SLICE CC_ROT MIRROR GROUPNUM VIEW FR L [sorted_view_list]sortsel ; by-view list, sorted by CCROT, in PRJ_DIR FR L [view_slice_lut]particle_lut_*** ; slice-to-particle lookup-table, in DF_DIR/VIEW_DIR ; ------------- END BATCH HEADER ------------------ ; set temporary filenames fr l [how_many]tmp_how_many fr l [temp_stack2particle_incore]tmp_stack2particle fr l [temp_df_view_slice_lut]tmp_dfslice_lut_incore fr l [temp_view_list_unrekeyed]tmp_view_list_unrekeyed fr l [temp_view_list_unreversed]tmpsort_unreversed ;;fr l ;;[temp_sorted_incore]tmpsort_incore md set mp (0) md vb off ; generate view-list doc create [ref_view_list] (1) ; column to be filled (1-x83) ; numbers to put in column VM echo "Separating particles for {***x83} reference views"; date x54=-1 ; initialize previous-micrograph# ; get #defocus-groups ud n,x75 [df_group_list] ; loop through defocus-groups do lb5 x77=1,x75 if (int(x77/x76).eq.x77/x76) then vm echo "Working on group #{***x77} out of {***x75}" endif ; GENERATE STACK-TO-PARTICLE LOOKUP TABLE ; get #particles ud n,[num-dfparticles] [group2micslice]x77 sd ic new [temp_stack2particle_incore] (4,[num-dfparticles]) ; #columns, #particles ; loop through particles do lb4 x40=1,[num-dfparticles] ; read group-slice# (x41), micrograph-rank# (x42), micrograph# (x55) ud ic,x40,x41,x42,x43,x55 [group2micslice]x77 ; if previous was different, then close previous if(x54.ne.x55) then ud ice [mic2global]x54 x54=x55 ; update previous endif ; read global-particle# (x46) ud ic,x42,x46 [mic2global]x55 ; write to lookup table sd ic x40,x46,x55,x42,x41 [temp_stack2particle_incore] ; WAS [stack2particle_lut]x77 ; global-particle# (x46), micrograph# (x55), micrograph-rank# (x42), group-slice# (x41) lb4 ; end particle-loop ; clean up ud ice [group2micslice]x77 ud ice [mic2global]x55 sd ic copy [temp_stack2particle_incore] [stack2particle_lut]x77 sd ic e [temp_stack2particle_incore] SD / PARTICLE MICROGRAPH MIC_SLICE GROUP_SLICE [stack2particle_lut]x77 sd e [stack2particle_lut]x77 ; GENERATE DEFOCUS-GROUP VIEW LIST ; create directories if needed vm echo "if(! -d [df_dir]/[view_dir]) mkdir -p [df_dir]/[view_dir]"|csh ; clean up pre-existing files x80=1 ; dummy variable de a [df_dir]/[view_dir]/[by_view_list]x80 ; split by view vo mq (0) ; CCC threshold [align_doc]x77 x83 ; #reference-projections [df_dir]/[view_dir]/[by_view_list] [df_dir]/[how_many] ; delete how_many file de [df_dir]/[how_many] lb5 ; end group-loop vm echo ; echo "Adding global particle numbers"; date ; Make sure output dir. present vm echo "if(! -d [view_dir]) mkdir [view_dir]"|csh ; clean up x80=1 ; dummy variable de a [view_dir]/[by_view_list]x80 ; loop through reference-views do lb8 x80=1,x83 if (int(x80/x56).eq.x80/x56) then vm echo "Working on view #{***x80} out of {***x83}" endif vm echo "if(! -d [prj_dir]) mkdir [prj_dir]"|csh ; SD / PARTICLE DF_SLICE CC_ROT MIRROR GROUPNUM VIEW ; [view_dir]/[by_view_list]x80 ; initialize combined particle-counter [combined-view-counter] = 0 ; loop through defocus-groups do lb7 x77=1,x75 ; get #particles in group->view ud n,x69 [df_dir]/[view_dir]/[by_view_list]x80 ; skip if empty if(x69.eq.0)goto lb7 sd ic new [temp_df_view_slice_lut] (4,x69) ; loop through particles do lb6 x60=1,x69 ; get slice# (x65), CCC (x63), mirror-flag (x64) ud ic,x60,x65,x63,x64 [df_dir]/[view_dir]/[by_view_list]x80 ; get particle# (x62) ud ic,x65,x62 [stack2particle_lut]x77 ; increment particle-counter [combined-view-counter] = [combined-view-counter]+1 ; write particle# (x62) for all-group view doc sd [combined-view-counter],x62,x65,x63,x64,x77,x80 [temp_view_list_unrekeyed] ; WAS [view_dir]/[by_view_list]x80 ; x62==particle#, x65==slice#, x63==CCC, x64==mirror-flag, x77=defocus-group, x80==view# ; write for current-group view doc also sd ic x60,x62,x65,x63,x64 [temp_df_view_slice_lut] ; WAS [df_dir]/[view_dir]/[view_slice_lut]x80 ; x62==particle#, x65==slice#, x63==CCC, x64==mirror-flag lb6 ; end particle-loop ; close documents sd ic copy [temp_df_view_slice_lut] [df_dir]/[view_dir]/[view_slice_lut]x80 sd ic e [temp_df_view_slice_lut] SD / PARTICLE SLICE CCC MIRROR [df_dir]/[view_dir]/[view_slice_lut]x80 sd e [df_dir]/[view_dir]/[view_slice_lut]x80 ud ice [df_dir]/[view_dir]/[by_view_list]x80 ud ice [stack2particle_lut]x77 lb7 ; end group-loop sd e ; close document [temp_view_list_unrekeyed] ; WAS [view_dir]/[by_view_list]x80 ; check if particle-list exists iq fi x68 [temp_view_list_unrekeyed] ; (will not exist if no particles in view) ; skip if particle-list doesn't exist if(x68.eq.0) then vm echo "No particles in view #{***x80} -- Skipping..." goto lb3 ; WAS lb8 endif ; re-key doc key [temp_view_list_unrekeyed] ; WAS [view_dir]/[by_view_list]x80 [view_dir]/[by_view_list]x80 ; WAS [temp_view_list_rekeyed] ; sort by CC doc sort [view_dir]/[by_view_list]x80 ; WAS [temp_view_list_rekeyed] ; INPUT [temp_view_list_unreversed] ; OUTPUT (4) ; column# to sort: CCROT Y ; renumber? ; reverse order, from highest to lowest @reversedoc_7col [temp_view_list_unreversed] ; INPUT [prj_dir]/[sorted_view_list] ; OUTPUT lb3 ; jump here if no particles in view ; label columns SD / VIEW_SLICE GLOBPARTICLE DF_SLICE CC_ROT MIRROR GROUPNUM VIEW [prj_dir]/[sorted_view_list] ; WAS [view_dir]/[sorted_view_list]x80 sd e [prj_dir]/[sorted_view_list] ; WAS [view_dir]/[sorted_view_list]x80 SD / VIEW_SLICE GLOBPARTICLE DF_SLICE CC_ROT MIRROR GROUPNUM VIEW [view_dir]/[by_view_list]x80 sd e [view_dir]/[by_view_list]x80 ; clean up de [temp_view_list_unreversed] de [temp_view_list_unrekeyed] lb8 ; end view-loop vm echo ; echo "Done"; date EN D ; Modified 2009-08-31 ; TO DO -- enable skipping of defocus-groups ; 2009-06-03 (trs) -- adding slice number as first column of select/sel ; 2009-05-15 (trs) -- added progress message going through defocus groups ; 2009-05-14 (trs) -- sorting by CCROT reversedoc_7col.spi ; 2009-04-22 (trs) -- using SD IC ; 2009-04-21 (trs) -- added version of select/sel sorted by CCROT ; 2009-02-23 (trs) -- added view# to select/sel output ; 2008-10-03 (trs) -- uses MIC2GLOBAL to get global particle# instead of SNDC ; 2008-04-24 (trs) -- number of reference projections now an input parameter ; 2008-01-30 (trs) -- added output stack2particle, which lists global particle# ; 2008-01-30 (trs) -- last angle in refangles not necessarily redundant ; 2007-08-07 (trs) -- reflects changes to input doc file sel_particles ; 2007-06-06 (trs) -- bug fix cleaning out pre-existing files, format change ; 2007-05-30 (trs) -- reflects changes to input doc file sel_particles ; 2007-03-27 (trs) -- reflects changes to input doc file sel_particles ; 2007-02-22 (trs & djt) -- use same names/labels for df***/select/sel and combined select/sel ; 2007-02-20 (trs & djt) -- projlist now an output ; 2007-02-20 (trs & djt) -- bug fix: defocus-group directories were not correctly created