6 # Copyright (C) 2002 Washington University School of Medicine
7 # and Howard Hughes Medical Institute
11 # Author: Christian M. Zmasek
12 # zmasek@genetics.wustl.edu
13 # http://www.genetics.wustl.edu/eddy/people/zmasek/
15 # Last modified: 02/20/02
20 # 0: first block in multiple alignment to process
21 # 1: last block in multiple alignment to process
22 # 2: name of resampled alignment, inc. query
26 # 6: seed for random number generator for neighbor
34 use lib $FindBin::Bin;
38 &dieWithUnexpectedError( "argument count is off" );
41 my $start = $ARGV[ 0 ];
43 my $align = $ARGV[ 2 ];
44 my $matrix_n = $ARGV[ 3 ];
45 my $name = $ARGV[ 4 ];
46 my $pwd_file = $ARGV[ 5 ];
47 my $seed = $ARGV[ 6 ];
48 my $number = $ARGV[ 7 ];
49 my $temp_dir = $ARGV[ 8 ];
53 my $mytemp_dir = $temp_dir."/dir_".$number;
55 mkdir( $mytemp_dir, 0700 )
56 || &dieWithUnexpectedError( "Could not create \"$mytemp_dir\"" );
58 unless ( ( -e $mytemp_dir ) && ( -d $mytemp_dir ) ) {
59 &dieWithUnexpectedError( "\"$mytemp_dir\" does not exist, or is not a directory" );
63 &executePuzzleDQObootstrapped( $align, $matrix_n );
65 system( "mv", $align.".dist", $mytemp_dir."/DISTs_TO_QUERY" )
66 && &dieWithUnexpectedError( "could not mv" );
72 ÷PWDfile( $pwd_file,
73 $mytemp_dir."/DIVIDED",
77 &addDistsToQueryToPWDfile( $mytemp_dir."/DIVIDED",
78 $mytemp_dir."/DISTs_TO_QUERY",
79 $mytemp_dir."/PWD_INC_QUERY",
82 unlink( $mytemp_dir."/DIVIDED" );
84 $b = $end - $start + 1;
87 || &dieWithUnexpectedError( "Could not chdir to \"$mytemp_dir\"" );
89 &executeNeighbor( $mytemp_dir."/PWD_INC_QUERY",
91 1, # randomize input order
93 1 ); # lower-triangular data matrix
96 unlink( "outfile", $mytemp_dir."/PWD_INC_QUERY", $mytemp_dir."/DISTs_TO_QUERY" );
98 system( "mv", "outtree", "../MAKETREEOUT".$MULTIPLE_TREES_FILE_SUFFIX.$number )
99 && &dieWithUnexpectedError( "could not mv" );
104 || &dieWithUnexpectedError( "Could not chdir to \"..\"" );
106 rmdir( $mytemp_dir ) || &dieWithUnexpectedError( "Could not delete \"$mytemp_dir\"" );
108 $outfile = "FINISHED_$number";
110 open( OUT, ">$outfile" ) || &dieWithUnexpectedError( "Cannot create file \"$outfile\"" );
119 my $pwd_file = $_[ 0 ];
120 my $outfile = $_[ 1 ];
121 my $start = $_[ 2 ]; # e.g. 0
122 my $end = $_[ 3 ]; # e.g. 9
126 my $return_line = "";
128 &testForTextFilePresence( $pwd_file );
130 open( IN_PWD, "$pwd_file" ) || &dieWithUnexpectedError( "Cannot open file \"$pwd_file\"" );
131 open( OUT_PWD, ">$outfile" ) || &dieWithUnexpectedError( "Cannot create file \"$outfile\"" );
133 while ( $return_line = <IN_PWD> ) {
134 if ( $return_line =~ /^\s*(\d+)\s*$/ ) {
135 if ( $c >= $start && $c <= $end ) {
138 elsif ( $c > $end ) {
144 print OUT_PWD $return_line;