-
Notifications
You must be signed in to change notification settings - Fork 0
/
count_particles.awk
executable file
·37 lines (29 loc) · 1.01 KB
/
count_particles.awk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /usr/bin/awk -f
# Count particles in each class from a class2D or class3D run_it***_data.star
# file from RELION.
# Usage:
# count_particles.awk run_it025_data.star
# Report which file is being analyzed.
$1 ~ /data_particles/ {
print "Analyzing star file:", FILENAME;
}
# Go through the file line by line and count how many times each class appears
# (each line is a particle). Only analyze lines with more than 2 fields.
NF > 10 {
# rlnClassNumber is the 3rd field in run_it***_data.star files from
# RELION-3.1.0. Change this if your version of RELION orders columns of star
# files differently.
rlnClassNumber = $3;
# Count particles in each class.
particles[rlnClassNumber]++;
# Count all particles.
total++;
}
# Report results.
END {
print "Total number of particles:", total;
printf("%5s\t%9s\t%10s\n", "Class", "Particles", "% of total");
for (i in particles) {
printf("%5d\t%9d\t%10.2f\n", i, particles[i], 100*particles[i]/total) | "sort -k 2 -n -r";
}
}