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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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
|