annotate PGAP_wrapper2.pl @ 8:86de4251345f draft

Uploaded
author dereeper
date Fri, 25 Jun 2021 20:00:00 +0000
parents 1085c917d850
children e0c913351502
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
1 #!/usr/bin/perl
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
2
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
3 use strict;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
4 use Getopt::Long;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
5 use Bio::SeqIO;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
6 use File::Basename;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
7 my $dirname = dirname(__FILE__);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
8 use Cwd qw(cwd);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
9 my $dir = cwd;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
10
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
11 my $usage = qq~Usage:$0 <args> [<opts>]
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
12
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
13 where <args> are:
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
14
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
15 -g, --genes <list of gene fasta files. Comma separated list>
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
16 -p, --proteins <list of protein fasta files. Comma separated list>
2
041355b97140 Uploaded
dereeper
parents: 1
diff changeset
17 -l, --list <list of samples in the same order. Comma separated list>
0
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
18 -o, --out <output name>
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
19 ~;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
20 $usage .= "\n";
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
21
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
22 my ($genes,$proteins,$out,$order);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
23
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
24 GetOptions(
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
25 "genes=s" => \$genes,
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
26 "proteins=s" => \$proteins,
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
27 "out=s" => \$out,
2
041355b97140 Uploaded
dereeper
parents: 1
diff changeset
28 "list=s" => \$order
0
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
29 );
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
30
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
31
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
32 die $usage
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
33 if ( !$proteins || !$genes || !$out || !$order);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
34
5
d8c5bea1cce2 Uploaded
dereeper
parents: 2
diff changeset
35 if ($order =~/^,(.*)$/){
d8c5bea1cce2 Uploaded
dereeper
parents: 2
diff changeset
36 $order = $1;
d8c5bea1cce2 Uploaded
dereeper
parents: 2
diff changeset
37 }
0
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
38 my @names = split(",",$order);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
39 mkdir("tmpdir$$");
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
40 my @gene_files = split(/,/,$genes);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
41 my $n = 0;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
42 foreach my $gene_file(@gene_files){
1
6d3580552457 Uploaded
dereeper
parents: 0
diff changeset
43 my $particule = $names[$n];
0
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
44 system("cp $gene_file tmpdir$$/$particule.nuc");
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
45 $n++;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
46 }
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
47 $n = 0;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
48 my @protein_files = split(/,/,$proteins);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
49 foreach my $protein_file(@protein_files){
5
d8c5bea1cce2 Uploaded
dereeper
parents: 2
diff changeset
50 my $particule = $names[$n];
0
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
51 system("cp $protein_file tmpdir$$/$particule.pep");
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
52 open(F,"$protein_file");
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
53 open(F2,">tmpdir$$/$particule.function");
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
54 while(<F>){
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
55 if (/>(.*)/){
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
56 print F2 "$1 - unknown\n";
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
57 }
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
58 }
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
59 close(F);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
60 close(F2);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
61 $n++;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
62 }
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
63
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
64 #chdir("$dirname/PGAP-1.2.1");
5
d8c5bea1cce2 Uploaded
dereeper
parents: 2
diff changeset
65 my $cmd = "perl $dirname/PGAP-1.2.1/PGAP.pl --input tmpdir$$ --output outdir --cluster --pangenome --variation --evolution --function --strains ".join("+",@names)." --method GF";
0
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
66 system($cmd);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
67 system("cp -rf outdir/1.Orthologs_Cluster.txt $out");
7
1085c917d850 Uploaded
dereeper
parents: 5
diff changeset
68 system("cat outdir/0.error.message");