5
This script will attempt to parse all cif files in
6
a given directory and save the parsed binaries.
10
parseMulti.pl [-i <input dir> -r -s <size> -o <output dir> -f <filter dict> -l <log file> -c]
15
-r recursively search all subdirectories
17
-f filter through dictionary
19
-c compress the binaries
20
-s size limit: skip files that are greater than <size> MB uncompressed
24
-i defaults to working directory if omitted
25
-o defaults to working directory if omitted
26
-l defaults to cifParse.log if omitted
34
use vars qw( $opt_i $opt_r $opt_o $opt_f $opt_l $opt_c $opt_s );
38
$opt_i or $opt_i = ".";
39
$opt_o or $opt_o = ".";
40
$opt_l or $opt_l = "cifParse.log";
42
my $compress = "/bin/compress -f";
43
my $uncompress = "/bin/uncompress -f";
45
my @tmp; # temporary file list (find command output)
46
my @files; # file list
48
my $uncompressed; # uncompressed file
49
my $status; # status of system call
51
my $parse_opt; # parse options
52
my $data; # parsed data object
53
my $filtered; # filtered data object
54
my $dict; # dictionary
55
my $date; # date and time
56
my $size; # size limit for files (uncompressed, in MB)
57
my $pwd; # working directory
59
if ( -e "temp.cif.Z" or -e "temp.cif" ) {
60
die "Please remove file(s) temp.cif* from working directory";
67
open (LOG, ">$opt_l");
68
print LOG "Working directory: $pwd";
69
print LOG "Directory of cif files: $opt_i\n";
70
print LOG "Subdirectories included? ", $opt_r?"yes":"no","\n";
71
print LOG "Size limit for uncompressed files? ", $opt_s?"$opt_s MB":"none", "\n";
72
print LOG "Dictionary used for filtering: ", $opt_f?"$opt_f":"none","\n";
78
$opt_f =~ /\.cob/ or die "Dictionary must be a binary (.cob file)";
79
$dict = STAR::Dictionary->new( $opt_f );
85
@tmp = `find $opt_i -name "*.cif" -print`;
86
@tmp = ( @tmp, `find $opt_i -name "*.cif.Z" -print` );
89
@tmp = `ls -1 $opt_i/*.cif $opt_i/*.cif.Z`;
97
print LOG "Started parsing: $date";
101
foreach $file ( sort @files ) {
103
$file =~ /(....)\.cif/;
106
if ( $file =~ /^(.*)\.Z/ ) {
108
eval{ system( "cp -f $file temp.cif.Z; $uncompress temp.cif.Z" ); };
110
&parse( "temp.cif", $file );
113
print LOG "Could not uncompress $file\n";
117
&parse( $file, $file );
121
eval{ system( "/bin/rm -f temp.cif" ); };
124
print LOG "Finished parsing: $date";
133
if ( $size > ( $opt_s * 1048576 ) ) {
134
print LOG "File $_[1] ($size bytes uncompressed) exceeds $opt_s MB size limit\n";
139
eval { ( $data ) = STAR::Parser->parse(-file=>$_[0]); };
142
print LOG "Could not parse $_[1]\n";
146
print LOG "Parsed $_[1]\n";
148
eval { $filtered = STAR::Filter->filter_through_dict(-data=>$data, -dict=>$dict); };
150
print LOG "Could not filter $_[0]\n";
154
$filtered->store( "$opt_o/$id.cob" );
158
$data->store( "$opt_o/$id.cob" );
163
eval{ system( "$compress $opt_o/$id.cob" ); };
165
print LOG "Could not compress $opt_o/$id.cob\n";