annotate PanExplorer_workflow/Perl/generateConfig.pl @ 2:97e4e3e818b6 draft

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