view PGAP_wrapper2.pl @ 6:c43a55b28d06 draft

Uploaded
author dereeper
date Fri, 25 Jun 2021 16:25:53 +0000
parents d8c5bea1cce2
children 1085c917d850
line wrap: on
line source

#!/usr/bin/perl

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

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");