aboutsummaryrefslogtreecommitdiff
path: root/scripts/split-indexed
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-07-22 14:08:15 -0700
committerThomas White <taw@physics.org>2013-07-22 14:08:44 -0700
commit3892f12e3920391e4acf539f79f976ad7eb921da (patch)
tree77dcb90ad8e5ec138ddeee8e693e2abfb9f2b711 /scripts/split-indexed
parent8c1fcaf82be3b3186f5f91d5a0d4583fdc2e6e10 (diff)
Add scripts/split-indexed
Diffstat (limited to 'scripts/split-indexed')
-rwxr-xr-xscripts/split-indexed78
1 files changed, 78 insertions, 0 deletions
diff --git a/scripts/split-indexed b/scripts/split-indexed
new file mode 100755
index 00000000..5c53214f
--- /dev/null
+++ b/scripts/split-indexed
@@ -0,0 +1,78 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+# Syntax: split-indexed input.stream \
+# output-cell.stream output-latt.stream output-raw.stream
+
+my $filename_cell = $ARGV[1];
+my $filename_latt = $ARGV[2];
+my $filename_raw = $ARGV[3];
+
+open(FH, $ARGV[0]);
+open(FH_CELL, ">".$filename_cell);
+open(FH_LATT, ">".$filename_latt);
+open(FH_RAW, ">".$filename_raw);
+
+my $line;
+my @chunk;
+my $indexed_by;
+my $not_indexed = 0;
+my $indexed_cell = 0;
+my $indexed_latt = 0;
+my $indexed_raw = 0;
+
+while ( $line = <FH> ) {
+
+ if ( $line =~ /^-----\ Begin chunk\ -----$/ ) {
+ $indexed_by = "";
+ while ( scalar(@chunk) ) {
+ my $l = shift(@chunk);
+ printf(FH_CELL "%s", $l);
+ printf(FH_LATT "%s", $l);
+ printf(FH_RAW "%s", $l);
+ }
+ @chunk = ();
+ }
+
+ push(@chunk, $line);
+
+ if ( $line =~ /^indexed_by\ =\ (.*)$/ ) {
+ $indexed_by = $1;
+ }
+
+ if ( $line =~ /^-----\ End chunk\ -----$/ ) {
+ if ( $indexed_by =~ /raw-nolatt/ ) {
+ $indexed_raw++;
+ while ( scalar(@chunk) ) {
+ printf(FH_RAW "%s", shift(@chunk));
+ }
+ } elsif ( $indexed_by =~ /^none$/ ) {
+ $not_indexed++;
+ @chunk = ();
+ } elsif ( $indexed_by =~ /raw-latt/ ) {
+ $indexed_latt++;
+ while ( scalar(@chunk) ) {
+ printf(FH_LATT "%s", shift(@chunk));
+ }
+ } else {
+ $indexed_cell++;
+ while ( scalar(@chunk) ) {
+ printf(FH_CELL "%s", shift(@chunk));
+ }
+ }
+ }
+
+}
+
+printf("%i patterns indexed using cell - written to %s.\n",
+ $indexed_cell, $filename_cell);
+printf("%i patterns indexed using lattice type only - written to %s.\n",
+ $indexed_latt, $filename_latt);
+printf("%i patterns indexed without prior cell or lattice information "
+ ."- written to %s.\n", $indexed_raw, $filename_raw);
+printf("%i unindexed patterns ignored.\n", $not_indexed);
+printf("%i total patterns\n",
+ $indexed_cell + $indexed_latt + $indexed_raw + $not_indexed);
+
+exit 0