#!/usr/bin/perl
use strict;
use warnings;

my $query;
my $SCAFFOLD;
my $start;
my $end;
my $identifyer;

my $query_name;

open (TABLE, '<', "regions.tab.tsv");

my $final_file;

while (<TABLE>) {
    my @row = split(/\t/,$_);
    $query = $row[0];
    $SCAFFOLD = $row[1];
    $start = $row[2];
    $end = $row[3];
    $identifyer = $row[4];

    system ("mkdir $identifyer");

    $final_file = "$identifyer/$SCAFFOLD.tcoffee";

    
    if ( !(-e $final_file) || (-z $final_file) )  
    {
	print "running code for $identifyer\n";
	system ("mv $query $identifyer");
	system ("cd $identifyer /home/u137272/Desktop/script2.pl $start $end $SCAFFOLD $query");
	system ("cd $identifyer mv $query /home/u137272/Desktop");
    }
    
}
close (TABLE);

