OSDN Git Service

Add: Grouping point for clustering. v2.0.2p0105
authorkinoshita-eos <kinoshita@yasunaga-lab.bio.kyutech.ac.jp>
Mon, 9 Mar 2015 09:00:33 +0000 (18:00 +0900)
committerkinoshita-eos <kinoshita@yasunaga-lab.bio.kyutech.ac.jp>
Mon, 9 Mar 2015 09:00:33 +0000 (18:00 +0900)
new file:   2DClustering/2DClustering1/GroupingPoint.pione
modified:   SampleCode/PIONE/Advanced5/Main.pione
new file:   SampleCode/PIONE/Advanced5/Main_ROI.pione
modified:   SampleCode/PIONE/Advanced5/Main_ROIr.pione

2DClustering/2DClustering1/GroupingPoint.pione [new file with mode: 0644]
SampleCode/PIONE/Advanced5/Main.pione
SampleCode/PIONE/Advanced5/Main_ROI.pione [new file with mode: 0644]
SampleCode/PIONE/Advanced5/Main_ROIr.pione

diff --git a/2DClustering/2DClustering1/GroupingPoint.pione b/2DClustering/2DClustering1/GroupingPoint.pione
new file mode 100644 (file)
index 0000000..da8d195
--- /dev/null
@@ -0,0 +1,78 @@
+# For GroupingPoint
+param $filename := "121p-shift2"
+param $ROT2 := (0.upto(3)) * 45
+param $divide := 4
+
+Rule Main
+       input '*.padsortlst'
+       input '{$I[1][1]}.treeinfo'
+       output '{$I[1][1]}.groupinfo'
+Action
+       cp {$I[1]} 1.lst
+       cp {$I[2]} 1.tree
+       for (( i=2; i<={$divide}; i++ ))
+       do
+               max=0
+               for data in $(ls *.lst)
+               do
+                       num=$(wc -l ${data} | awk '{printf $1}')
+                       if [ ${num} -gt ${max} ] ; then
+                               max=${num}
+                               maxlist="${data}"
+                       fi
+               done
+               maxtree="$(basename ${maxlist} '.lst').tree"
+               root=$(head -1 ${maxtree} | awk '{printf("%d", $1)}')
+               rootname=$(basename $(awk -v val=${root} '$2==val {printf("%s", $1)}' ${maxlist}) ".pad")
+               cp ${maxlist} ${rootname}.avglst
+               maxpos=$(awk -v val=${root} '$2==val {printf("%f", $3)}' ${maxlist})
+               line=$(awk -v val=${root} '$2==val {print NR}' ${maxlist})
+               head -$((${line} - 1)) ${maxlist} > ${i}.lst
+               tail -$(($(wc -l ${maxlist} | awk '{print $1}') - ${line} + 1)) ${maxlist} > tmp
+               cp tmp ${maxlist}
+               
+               max_t=$(wc -l ${maxtree} | awk '{printf $1}')
+               max_l=$(wc -l ${maxlist} | awk '{printf $1}')
+               line_t=$(awk -v val=${root} '$1==val {print NR}' ${maxtree})
+               head -$((${max_l} + ${line_t} - 1)) ${maxtree} | tail -$((${max_l} - 1)) > tmp
+               tail -$((${max_t} - ${max_l})) ${maxtree} > ${i}.tree
+               cp tmp ${maxtree}
+       done
+       
+       array_rot2=( {$ROT2} )
+
+       total=0
+       element_total=0
+       for lst in $(ls *.lst)
+       do
+               num=$(basename ${lst} ".lst")
+               element_num=$(wc -l ${num}.lst | awk '{print $1}')
+               element_total=$(( ${element_total} + ${element_num} ))
+               data=$(head -1 ${num}.tree)
+               root_i=$(echo ${data} | awk '{print $1}')
+               root_name=$(basename $(awk -v i=${root_i} '$2==i {print $1}' ${num}.lst) ".pad")
+       
+               max=0
+               max_i=0
+               i=0
+               include_max_rot2=${array_rot2[0]}
+               for rot2 in ${array_rot2[@]}
+               do
+                       include_num=$(grep "{$filename}-0-${rot2}-" ${num}.lst | wc -l | awk '{print $1}')
+                       if [ ${include_num} -gt ${max} ] ; then
+                               max=${include_num}
+                               include_max_rot2=${rot2}
+                               max_i=${i}
+                       fi
+                       i=$(( ${i} + 1 ))
+               done
+               
+               echo "group${root_i}:   match:  ${max}  owner:  ${include_max_rot2}" >> {$O[1]}
+               total=$(( ${total} + ${max} ))
+               
+               unset array_rot2[${max_i}]
+               array_rot2=("${array_rot2[@]}")
+       done
+       echo "                          total:  ${total}" >> {$O[1]}
+       echo "${total} ${element_total}" | awk '{printf("parcentage:    %f\n", $1 / $2)}' >> {$O[1]}
+End
index 222831f..ddc61eb 100644 (file)
@@ -1,6 +1,6 @@
-param $task := 2
-param $divide := 2
-param $refine := 5 
+param $task := 4
+param $divide := 4
+param $refine := 0#
 
 # Cluster Name
 param $CLUSTER := "all"
@@ -16,7 +16,7 @@ param $SHRINK := 1
 param $PADMODE := 13
 #  LOWPASS
 param $LowPassMode := 4 
-param $LowPassResolution := 0.1
+param $LowPassResolution := 0.085
 
 # Clustering
 param $ClusterCorrelationMode := 19
@@ -58,19 +58,27 @@ $Config :=  ("CLUSTER":$CLUSTER) |
                        ("TreeScaleY":$TreeScaleY) |
                        ("TreeOffset":$TreeOffset)
 
+# For GroupingPoint
+param $filename := "121p-shift2"
+param $ROT2 := (0.upto(3)) * 45
+
 Rule Main
        input '*.roi'.all
        input 'Makefile'
+       output '*.pad'.all
        output '*.avg'.all
        output '*.tiff'.all
-       output 'all.logps'
-       output 'all.treeinfo'
-       output 'all.avgsortlst'
+       output '{$CLUSTER}.logps'
+       output '{$CLUSTER}.treeinfo'
+       output '{$CLUSTER}.padsortlst'
+       output '{$CLUSTER}.avgsortlst'
+       output '*.avg*'.all
+       output '*.groupinfo'.all
 Flow
        rule SetParam
        rule Preprocess {filelist:$I[1].all, num:1.upto($task), length:$I[1].length()}
        rule Process
-       rule Refinement {num:1.upto($divide)}
+       rule Refinement {num:1.upto($divide)} >>> GroupingPoint
        rule RefinementRoot
        rule MontageAverage
 End
@@ -102,23 +110,23 @@ Rule Process
        input '*.pad'.all
        input 'Makefile'
        input 'Makefile.config'
-       output 'all.padsortlst'
-       output 'all.treeinfo'
-       output 'all.avgsortlst'
+       output '{$CLUSTER}.padsortlst'
+       output '{$CLUSTER}.treeinfo'
+       output '{$CLUSTER}.avgsortlst'
        output ((1.upto($divide).str())+".lst").d().all()
        output ((1.upto($divide).str())+".tree").d().all()
        output ("*.pad"+(1.upto($divide).str())).d().all()
        output ("*.avg"+(0.upto($divide).str())).d().all()
        output '*.avglst'.all
-       output 'all.padsortmon.tiff'
-       output 'all.avgsortmon.tiff'
-       output 'all.logps'
+       output '{$CLUSTER}.padsortmon.tiff'
+       output '{$CLUSTER}.avgsortmon.tiff'
+       output '{$CLUSTER}.logps'
 Action
-       ls -1 *.pad > all.padlst
+       ls -1 *.pad > {$CLUSTER}.padlst
        make Log
        make LogPS
-       mrc2tiff -i all.padsortmon -o all.padsortmon.tiff
-       mrc2tiff -i all.avgsortmon -o all.avgsortmon.tiff
+       mrc2tiff -i {$CLUSTER}.padsortmon -o {$CLUSTER}.padsortmon.tiff
+       mrc2tiff -i {$CLUSTER}.avgsortmon -o {$CLUSTER}.avgsortmon.tiff
        
        cp {$O[1]} 1.lst
        cp {$O[2]} 1.tree
@@ -174,10 +182,10 @@ Rule Refinement
 Action
        max=$(wc -l {$num}.tree | awk '{printf $1}')
        data=$(head -1 {$num}.tree)
-       i=$(echo ${data} | awk '{print $1}')
-       name=$(basename $(awk -v i=${i} '$2==i {print $1}' {$num}.lst) ".pad")
-       cp {$num}.lst ${name}.avglst
-       cp {$num}.tree ${name}.tree
+       root_i=$(echo ${data} | awk '{print $1}')
+       root_name=$(basename $(awk -v i=${root_i} '$2==i {print $1}' {$num}.lst) ".pad")
+       cp {$num}.lst ${root_name}.avglst
+       cp {$num}.tree ${root_name}.tree
        
        for (( k=1; k<=max ; k++ ))
        do
@@ -230,6 +238,7 @@ Action
                        
                        mrcImageAverage -i ${name}.fitlst -o ${name}.pad.avg
                done
+
                mrc2tiff -i ${name}.pad.avg -o ${name}.pad.avg.tiff
                mrc2tiff -i ${name}.pad.avg{$num} -o ${name}.pad.avg{$num}.tiff
        done
@@ -251,7 +260,7 @@ Action
        ClusterRotationRangePartitionNumber=$(awk '$1=="ClusterRotationRangePartitionNumber" {print $2}' Makefile.config.tmp)
        ClusterRotationIterationNumber=$(awk '$1=="ClusterRotationIterationNumber" {print $2}' Makefile.config.tmp)
        ClusterRotationCorrelationMode=$(awk '$1=="ClusterRotationCorrelationMode" {print $2}' Makefile.config.tmp)
-       
+
        for data in $(ls *.avglst)
        do
                name=$(basename ${data} ".avglst")
@@ -268,17 +277,60 @@ Action
                        
                        mrcImageAverage -i ${name}.fitlst -o ${name}.pad.avg
                done
+               
                mrc2tiff -i ${name}.pad.avg -o ${name}.pad.avg.tiff
                mrc2tiff -i ${name}.pad.avg0 -o ${name}.pad.avg0.tiff
        done
 End
 
+Rule GroupingPoint
+       input '*.lst'.all
+       input '*.tree'.all
+       output '{$CLUSTER}.groupinfo'
+Action
+       array_rot2=( {$ROT2} )
+
+       total=0
+       element_total=0
+       for num in {$I[1][1]}
+       do
+               element_num=$(wc -l ${num}.lst | awk '{print $1}')
+               element_total=$(( ${element_total} + ${element_num} ))
+               data=$(head -1 ${num}.tree)
+               root_i=$(echo ${data} | awk '{print $1}')
+               root_name=$(basename $(awk -v i=${root_i} '$2==i {print $1}' ${num}.lst) ".pad")
+       
+               max=0
+               max_i=0
+               i=0
+               include_max_rot2=${array_rot2[0]}
+               for rot2 in ${array_rot2[@]}
+               do
+                       include_num=$(grep "{$filename}-0-${rot2}-" ${num}.lst | wc -l | awk '{print $1}')
+                       if [ ${include_num} -gt ${max} ] ; then
+                               max=${include_num}
+                               include_max_rot2=${rot2}
+                               max_i=${i}
+                       fi
+                       i=$(( ${i} + 1 ))
+               done
+               
+               echo "group${root_i}:   match:  ${max}  owner:  ${include_max_rot2}" >> {$O[1]}
+               total=$(( ${total} + ${max} ))
+               
+               unset array_rot2[${max_i}]
+               array_rot2=("${array_rot2[@]}")
+       done
+       echo "                          total:  ${total}" >> {$O[1]}
+       echo "${total} ${element_total}" | awk '{printf("parcentage:    %f\n", $1 / $2)}' >> {$O[1]}
+End
+
 Rule MontageAverage
-       input 'all.avgsortlst'
-       input 'all.treeinfo'
+       input '{$CLUSTER}.avgsortlst'
+       input '{$CLUSTER}.treeinfo'
        input '*.pad.avg'.all
-       output 'all.avgrefinemon'
-       output 'all.avgrefinemon.tiff'
+       output '{$CLUSTER}.avgrefinemon'
+       output '{$CLUSTER}.avgrefinemon.tiff'
 Action
        root=$(head -1 {$I[2]} | awk '{print $1}')
        root_file=$(awk -v val=${root} '$2==val {print $1}' {$I[1]})
diff --git a/SampleCode/PIONE/Advanced5/Main_ROI.pione b/SampleCode/PIONE/Advanced5/Main_ROI.pione
new file mode 100644 (file)
index 0000000..04107a5
--- /dev/null
@@ -0,0 +1,70 @@
+Rule Main
+       input '*.ref3d'
+       output '*.roi'.all
+       output '*.tiff'.all
+       param $X_SIZE := 32
+       param $Y_SIZE := 32
+       param $ROI_ROT_MODE := "XEYS"
+       param $ROI_ROT1_MIN := 0
+       param $ROI_ROT1_MAX := 0
+       param $ROI_ROT1_DELTA := 45
+       $ROI_ROT1 := (((0.upto(($ROI_ROT1_MAX - $ROI_ROT1_MIN) / $ROI_ROT1_DELTA)) * $ROI_ROT1_DELTA) + $ROI_ROT1_MIN).all
+       param $ROI_ROT2_MIN := 0
+       param $ROI_ROT2_MAX := 135
+       param $ROI_ROT2_DELTA := 45
+       $ROI_ROT2 := (((0.upto(($ROI_ROT2_MAX - $ROI_ROT2_MIN) / $ROI_ROT2_DELTA)) * $ROI_ROT2_DELTA) + $ROI_ROT2_MIN).all
+       param $ROI_ROT3_MIN := 0
+       param $ROI_ROT3_MAX := 270
+       param $ROI_ROT3_DELTA := 30
+       $ROI_ROT3 := (((0.upto(($ROI_ROT3_MAX - $ROI_ROT3_MIN) / $ROI_ROT3_DELTA)) * $ROI_ROT3_DELTA) + $ROI_ROT3_MIN).all
+       param $ROI_SN := 0.9
+Action
+       data=$(mrcInfo -i {$I[1]} | head -1)
+       x_size=$(echo "${data}" | awk '{printf ("%i", $4)}')
+       y_size=$(echo "${data}" | awk '{printf ("%i", $5)}')
+       z_size=$(echo "${data}" | awk '{printf ("%i", $6)}')
+
+       data=$(mrcInfo -i {$I[1]} | head -5 | tail -1)
+       x_length=$(echo "${data}" | awk '{printf ("%f", $4)}')
+       y_length=$(echo "${data}" | awk '{printf ("%f", $5)}')
+       z_length=$(echo "${data}" | awk '{printf ("%f", $6)}')
+       
+       ref_size=${x_size}
+       length=${x_length}
+       
+       if [ ${ref_size} -lt ${y_size} ] ; then \
+               ref_size=${y_size}
+               length=${y_length}
+       fi
+       
+       if [ ${ref_size} -lt ${z_size} ] ; then \
+               ref_size=${z_size}
+               length=${z_length}
+       fi
+       
+       image_size={$X_SIZE}
+       
+       if [ ${image_size} -lt {$Y_SIZE} ] ; then \
+               image_size={$Y_SIZE}
+       fi
+       
+       sampling_length=$(echo "scale=7; ${length} * ${ref_size} / ${image_size}" | bc)
+       
+       mrcImageSamplingUnitChange -i {$I[1]} -o {$I[1][1]}.sample3d -m 2 -S ${sampling_length} ${sampling_length} ${sampling_length}
+
+       for rot1 in {$ROI_ROT1}
+       do
+               for rot2 in {$ROI_ROT2}
+               do
+                       for rot3 in {$ROI_ROT3}
+                       do
+                               mrc3Dto2D       -i {$I[1][1]}.sample3d -o {$I[1][1]}-${rot1}-${rot2}-${rot3}.data2d -InterpolationMode 2 -EulerMode {$ROI_ROT_MODE} \
+                                                       -Rot1 ${rot1} ${rot1} 1 \
+                                                       -Rot2 ${rot2} ${rot2} 1 \
+                                                       -Rot3 ${rot3} ${rot3} 1
+                               mrcImageNoiseAdd -i {$I[1][1]}-${rot1}-${rot2}-${rot3}.data2d -o {$I[1][1]}-${rot1}-${rot2}-${rot3}-{$ROI_SN}.roi -SN {$ROI_SN}
+                               mrc2tiff -i {$I[1][1]}-${rot1}-${rot2}-${rot3}-{$ROI_SN}.roi -o {$I[1][1]}-${rot1}-${rot2}-${rot3}-{$ROI_SN}.tiff
+                       done
+               done
+       done
+End
index 0bd60ce..bcaf461 100644 (file)
@@ -2,14 +2,15 @@ Rule Main
        input '*.ref3d'
        output '*.roi'.all
        output '*.tiff'.all
-       param $X_SIZE := 32
-       param $Y_SIZE := 32
+       #output '*.ref2d'.all
+       param $X_SIZE := 64#32
+       param $Y_SIZE := 64#32
        param $ROI_ROT_MODE := "XEYS"
-       param $ROI_ROT1_NUM := 3
-       param $ROI_ROT2_NUM := 3
-       param $ROI_ROT3_NUM := 3
-       param $ROI_SHIFT_NUM := 2
-       param $ROI_SN := 1
+       param $ROI_ROT1_NUM := 1#3
+       param $ROI_ROT2_NUM := 4#3
+       param $ROI_ROT3_NUM := 10
+       param $ROI_SHIFT_NUM := 1#2
+       param $ROI_SN := 0.3
        param $ROI_NOISE_NUM := 1
 Action
        data=$(mrcInfo -i {$I[1]} | head -1)
@@ -66,6 +67,10 @@ Action
                                        done
                                done
                        done
+                       #mrc3Dto2D      -i {$I[1][1]}.sample3d -o all.ref2d -InterpolationMode 2 -EulerMode {$ROI_ROT_MODE} \
+                       #                       -Rot1 ${rot1} ${rot1} 1 \
+                       #                       -Rot2 ${rot2} ${rot2} 1 \
+                       #                       -Rot3 0 0 1
                done
        done
 End