annotate generateConfig.pl @ 17:db83eb7c8f78 draft default tip

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