1
|
1 #!/usr/bin/perl
|
|
2
|
|
3 use strict;
|
|
4 use warnings;
|
|
5 use YAML qw(DumpFile);
|
|
6
|
|
7 use Cwd;
|
|
8 my $dir = getcwd;
|
|
9
|
|
10
|
|
11 my $zip = $ARGV[0];
|
|
12 my $list = $ARGV[1];
|
|
13 my $out = $ARGV[2];
|
|
14 my $zip_fasta = $ARGV[3];
|
|
15
|
|
16 $list =~s/NZ_//g;
|
|
17 my @list_ids = split(/,/,$list);
|
|
18
|
|
19 my %data = ();
|
|
20 foreach my $id(@list_ids){
|
|
21 push @{$data{"ids"}}, "$id";
|
|
22 }
|
|
23 # case fasta+gff
|
|
24 if ($zip ne "None" && $zip_fasta ne "None"){
|
|
25 system("rm -rf $zip.genomeszip");
|
|
26 mkdir("$zip.genomeszip");
|
|
27 chdir("$zip.genomeszip");
|
|
28 system("cp -rf $zip ./genomes.zip");
|
|
29 system("cp -rf $zip_fasta ./fasta_genomes.zip");
|
|
30 system("unzip fasta_genomes.zip");
|
|
31 system("unzip genomes.zip");
|
|
32 unlink("fasta_genomes.zip");
|
|
33 unlink("genomes.zip");
|
|
34 open(LS,"ls *gff |");
|
|
35 while(my $line = <LS>){
|
|
36 chomp($line);
|
|
37 my $concat = "$zip.genomeszip/".$line;
|
|
38 if ($line =~/(.*)\.gff/){
|
|
39 my $name = $1;
|
|
40 if ($concat =~/\w+/){
|
|
41 $data{"input_genomes"}{"$name"}{"gff3"} = "$concat";
|
|
42 $data{"input_genomes"}{"$name"}{"name"} = "$name";
|
|
43 }
|
|
44 }
|
|
45 }
|
|
46 close(LS);
|
|
47
|
|
48 open(LS,"ls *fasta |");
|
|
49 while(my $line = <LS>){
|
|
50 chomp($line);
|
|
51 my $concat = "$zip.genomeszip/".$line;
|
|
52 if ($line =~/(.*)\.fasta/){
|
|
53 my $name = $1;
|
|
54 if ($concat =~/\w+/){
|
|
55 $data{"input_genomes"}{"$name"}{"fasta"} = "$concat";
|
|
56 }
|
|
57 }
|
|
58 }
|
|
59 close(LS);
|
|
60
|
|
61 }
|
|
62 elsif ($zip ne "None"){
|
|
63 system("rm -rf $zip.genomeszip");
|
|
64 mkdir("$zip.genomeszip");
|
|
65 chdir("$zip.genomeszip");
|
|
66 my $head = `head -1 $zip`;
|
|
67 if ($head =~/LOCUS/){
|
|
68 push @{$data{"input_genbanks"}}, "$zip";
|
|
69 }
|
|
70 else{
|
|
71 system("cp -rf $zip ./genomes.zip");
|
|
72 system("unzip genomes.zip");
|
|
73 unlink("genomes.zip");
|
|
74 open(LS,"ls |");
|
|
75 while(my $line = <LS>){
|
|
76 chomp($line);
|
|
77 my $concat = "$zip.genomeszip/".$line;
|
|
78 if ($concat =~/\w+/){
|
|
79 push @{$data{"input_genbanks"}}, "$concat";
|
|
80 }
|
|
81 }
|
|
82 close(LS);
|
|
83 }
|
|
84 }
|
|
85 #else{
|
|
86 # push @{$data{"input_genbanks"}}, "";
|
|
87 #}
|
|
88 chdir($dir);
|
|
89
|
|
90 DumpFile($out, \%data);
|