File: makeMauveWargFile.pl

package info (click to toggle)
clonalorigin 1.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,800 kB
  • sloc: cpp: 10,488; perl: 349; xml: 130; makefile: 48; sh: 33
file content (39 lines) | stat: -rwxr-xr-x 1,111 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl -w
use IO::Compress::Bzip2 qw(bzip2 $Bzip2Error) ;

use strict;

my $maxfile = -1;
for( my $i=0; $i < (@ARGV) - 1; $i++){
	my $fI = $ARGV[$i];
	$fI =~ s/.*\.(\d+)\.xml.bz2/$1/g;
	$maxfile = $fI if($fI>$maxfile);
}
print "Found $maxfile xml block files\n";

my $base = $ARGV[0];
$base =~ s/(.*)\.\d+\.xml.bz2/$1/g;

my $zout = new IO::Compress::Bzip2 "$base.mauveConcat.bz2" or die "bzip2 failed: $Bzip2Error\n";
$zout->print("<?xml version = '1.0' encoding = 'UTF-8'?>\n");
$zout->print("<weakArgData>\n");
for( my $i=1; $i<=$maxfile; $i++ ){
	unless( -e "$base.$i.xml.bz2" ){
		# output file doesn't exist, so create an empty block placeholder
		$zout->print("<outputFile>\n");
		$zout->print("<Blocks>\n");
		$zout->print("</Blocks>\n");
		$zout->print("<comment>Empty placeholder for missing block $i</comment>\n");
		$zout->print("</outputFile>\n");
		next;
	}
	open( CURFILE, "bzcat $base.$i.xml.bz2 |" );
	while( my $line = <CURFILE> ){
		next if substr($line, 0, 5) eq "<?xml";
		$zout->print($line);
	}
	close CURFILE;
}
$zout->print("</weakArgData>\n");
$zout->flush();
$zout->close();