#!usr/bin/perl use DBI; use Data::Dumper; use strict; use warnings; use CGI; my $filename = $ARGV[0]; my $tablename = $ARGV[1]; my $outfile = $ARGV[2]; open(INPUT, $filename); my $line; my $i; my $sth; while ($line = ) { # Get the block identifier my $blockID; $line = ; chomp($line); $blockID = $line; $i++; #print "\n"."New block: $blockID"."\n"; # Skip the next four lines ; ; ; ; open (MYOUTFILE, ">>./tmp/$outfile"); while ($line = ) { chomp($line); if (! $line) { last; } else { my $tmp = index($line, '#'); if ($tmp == -1) # alignment lines { if (index($line, '*') == -1) { #print "$line\n"; } } if ($tmp == 0) # genomic positions { #print "$line\n"; my @fields = split('\t', $line); my $tmp = $fields[1]; @fields = split(':', $tmp); my $chrom = $fields[1]; my $start = $fields[2]; my $stop = $fields[3]; #print "$i\t\$blockID\n"; #print "$i\t$line\t$chrom\t$start\t$stop\t$blockID\n"; print MYOUTFILE"$i\t$start\t$stop\t$chrom\t$blockID\n"; } } } } close (MYOUTFILE); close (INPUT);