view PGAP_wrapper2.pl @ 3:bbb2c473664c draft

Uploaded
author dereeper
date Thu, 24 Jun 2021 15:08:13 +0000
parents 041355b97140
children d8c5bea1cce2
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);

my @names = split(",",$order);
my @list;
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[0];
	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("+",@list)." --method GF";
system($cmd);
system("cp -rf outdir/1.Orthologs_Cluster.txt $out");