view PGAP_wrapper2.pl @ 11:e0c913351502 draft default tip

Uploaded
author dereeper
date Thu, 01 Jul 2021 12:22:53 +0000
parents 1085c917d850
children
line wrap: on
line source

#!/usr/bin/perl

use strict;
use Getopt::Long;
use Bio::SeqIO;
use File::Basename;
my $dirname = dirname(__FILE__);

my $usage = qq~Usage:$0 <args> [<opts>]

where <args> are:

    -g, --genes          <list of gene fasta files. Comma separated list>
    -p, --proteins       <list of protein fasta files. Comma separated list>
    -l, --list           <list of samples in the same order. Comma separated list>
    -o, --out            <output name>      
~;
$usage .= "\n";

my ($genes,$proteins,$out,$order);

GetOptions(
"genes=s"        => \$genes,
"proteins=s"     => \$proteins,
"out=s"          => \$out,
"list=s"        => \$order
);


die $usage
  if ( !$proteins || !$genes || !$out || !$order);

if ($order =~/^,(.*)$/){
	$order = $1;
}
my @names = split(",",$order);
mkdir("tmpdir$$");
my @gene_files = split(/,/,$genes);
my $n = 0;
foreach my $gene_file(@gene_files){
	my $particule = $names[$n];
	system("cp $gene_file tmpdir$$/$particule.nuc");
	$n++;
}
$n = 0;
my @protein_files = split(/,/,$proteins);
foreach my $protein_file(@protein_files){
        my $particule = $names[$n];
	system("cp $protein_file tmpdir$$/$particule.pep");
	open(F,"$protein_file");
	open(F2,">tmpdir$$/$particule.function");
	while(<F>){
		if (/>(.*)/){
			print F2 "$1	-	unknown\n";	
		}
	}
	close(F);
	close(F2);
	$n++;
}

#chdir("$dirname/PGAP-1.2.1");
my $cmd = "perl $dirname/PGAP-1.2.1/PGAP.pl --input tmpdir$$ --output outdir --cluster --pangenome --variation --evolution --function --strains ".join("+",@names)." --method GF";
system($cmd);
system("cp -rf outdir/1.Orthologs_Cluster.txt $out");
system("cat outdir/0.error.message");