comparison generateConfig.pl @ 16:1e0698511c9f draft

Uploaded
author dereeper
date Sun, 15 Dec 2024 21:30:16 +0000
parents
children
comparison
equal deleted inserted replaced
15:dbde253606c5 16:1e0698511c9f
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 # case list of accessions
21 if ($list ne 'None'){
22 foreach my $id(@list_ids){
23 push @{$data{"ids"}}, "$id";
24 }
25 }
26 # case fasta+gff
27 elsif ($zip ne "None" && $zip_fasta ne "None"){
28 system("rm -rf $zip.genomeszip");
29 mkdir("$zip.genomeszip");
30 chdir("$zip.genomeszip");
31 system("cp -rf $zip ./genomes.zip");
32 system("cp -rf $zip_fasta ./fasta_genomes.zip");
33 system("unzip fasta_genomes.zip");
34 system("unzip genomes.zip");
35 unlink("fasta_genomes.zip");
36 unlink("genomes.zip");
37 open(LS,"ls *gff |");
38 while(my $line = <LS>){
39 chomp($line);
40 my $concat = "$zip.genomeszip/".$line;
41 if ($line =~/(.*)\.gff/){
42 my $name = $1;
43 if ($concat =~/\w+/){
44 $data{"input_genomes"}{"$name"}{"gff3"} = "$concat";
45 $data{"input_genomes"}{"$name"}{"name"} = "$name";
46 }
47 }
48 }
49 close(LS);
50
51 open(LS,"ls *fasta |");
52 while(my $line = <LS>){
53 chomp($line);
54 my $concat = "$zip.genomeszip/".$line;
55 if ($line =~/(.*)\.fasta/){
56 my $name = $1;
57 if ($concat =~/\w+/){
58 $data{"input_genomes"}{"$name"}{"fasta"} = "$concat";
59 }
60 }
61 }
62 close(LS);
63
64 }
65 elsif ($zip ne "None"){
66 system("rm -rf $zip.genomeszip");
67 mkdir("$zip.genomeszip");
68 chdir("$zip.genomeszip");
69 my $head = `head -1 $zip`;
70 if ($head =~/LOCUS/){
71 push @{$data{"input_genbanks"}}, "$zip";
72 }
73 else{
74 system("cp -rf $zip ./genomes.zip");
75 system("unzip genomes.zip");
76 unlink("genomes.zip");
77 open(LS,"ls |");
78 while(my $line = <LS>){
79 chomp($line);
80 my $concat = "$zip.genomeszip/".$line;
81 if ($concat =~/\w+/){
82 push @{$data{"input_genbanks"}}, "$concat";
83 }
84 }
85 close(LS);
86 }
87 }
88 #else{
89 # push @{$data{"input_genbanks"}}, "";
90 #}
91 chdir($dir);
92
93 DumpFile($out, \%data);