annotate Perl/generateConfig.pl @ 6:35d71348e81e draft

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