[Bio] / SubsystemExtension / cluster_detection.pl Repository:
ViewVC logotype

View of /SubsystemExtension/cluster_detection.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu Jan 5 19:41:53 2006 UTC (13 years, 10 months ago) by olson
Branch: MAIN
CVS Tags: HEAD
Rearrangement for easier installation.

#!/Users/fig/FIGDisk/env/mac/bin/perl 

use strict;
use warnings;

use Getopt::Std;
use Term::ReadKey;
use IO::Handle;
use Data::Dumper;

use SubsystemExtension::ClusterDetectionSparse;
#use SubsystemExtension::ClusterDetectionArray;
use SubsystemExtension::SequenceFactory::SEED;
use SubsystemExtension::SequenceFactory::COG;


use constant DEBUG => 1;
no warnings qw(redefine);

#
#  this is necessary if the script is started via rsh(1)
#  otherwise you won't see any output until the first <RETURN>
#


sub usage {
    print "-= cluster_detection =-\n\n";
    print "usage:\n cluster_detection -s <seed_taxon_id file> -f <cog file> -d <validation_directory> -t <family type ('cog', 'kegg' ettc.)> -c <min cluster size> -g <min cluster size genomes> -o <min cluster overlap>\n\n";
    
}

# global variables
our( $opt_f, $opt_d, $opt_s, $opt_t, $opt_c, $opt_g, $opt_o, $opt_a, $opt_p);

getopts('f:d:s:t:c:g:o:pa');


if (!$opt_f && !$opt_s) {
    usage;
    print "ERROR: Can't start script : no cog filename given!\n";
    exit 1;
}


print STDERR $opt_p;

$opt_c = $opt_c ? $opt_c : 2;
$opt_g = $opt_g ? $opt_g : 2;
$opt_o = $opt_o ? $opt_o : 75;


my $gecko;
if ($opt_a) {

	print STDERR "Using Array variant\n";
#	$gecko = SubsystemExtension::ClusterDetectionArray->new($opt_c, $opt_g, $opt_o, $opt_p);
} else {
	print STDERR "Using Sparse variant\n";
	$gecko = SubsystemExtension::ClusterDetectionSparse->new($opt_c, $opt_g, $opt_o, $opt_p, $opt_d);

}
if (ref $gecko) {

	my ($sequences, $genomes, $factory);
	

	
	if ($opt_f && -e $opt_f) {
		
		$factory = SubsystemExtension::SequenceFactory::COG->new($opt_f);
		
	}  elsif ($opt_s && -e $opt_s) {
		
		my @taxon_ids;
		
		open (TAXON_IDS, "<".$opt_s)  or die "could not open $opt_s\n";
		while (<TAXON_IDS>) {
			chomp;
			push @taxon_ids, $_;
			print STDERR "$_\n";
		}

		close (TAXON_IDS);
		$factory = SubsystemExtension::SequenceFactory::SEED->new(\@taxon_ids, $opt_t ? $opt_t : 'cog');
		
	}
	close STDOUT;

	($sequences, $genomes) = $factory->createSequences();

	# print STDERR &Dumper($sequences);
	$gecko->sequences($sequences);
	$gecko->genomes($genomes);
	$gecko->connecting_intervalls();

	my $clusterList = $gecko->clusterList();
	
	$clusterList->toFile($opt_d."/clusterlist.cls");
	foreach my $cluster ($clusterList->clusters()) {
	    $cluster->toFile($opt_d."/cluster_".$cluster->{id}.".cls");
	}
	
}

		
    




MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3