diff Perl/generateConfig.pl @ 3:e42d30da7a74 draft

Uploaded
author dereeper
date Thu, 30 May 2024 11:52:25 +0000
parents
children 5a5c9a6b047b
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Perl/generateConfig.pl	Thu May 30 11:52:25 2024 +0000
@@ -0,0 +1,90 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use YAML qw(DumpFile);
+
+use Cwd;
+my $dir = getcwd;
+
+
+my $zip = $ARGV[0];
+my $list = $ARGV[1];
+my $out = $ARGV[2];
+my $zip_fasta = $ARGV[3];
+
+$list =~s/NZ_//g;
+my @list_ids = split(/,/,$list);
+
+my %data = ();
+foreach my $id(@list_ids){
+	push @{$data{"ids"}}, "$id";
+}
+# case fasta+gff
+if ($zip ne "None" && $zip_fasta ne "None"){
+	system("rm -rf $zip.genomeszip");
+	mkdir("$zip.genomeszip");
+	chdir("$zip.genomeszip");
+	system("cp -rf $zip ./genomes.zip");
+	system("cp -rf $zip_fasta ./fasta_genomes.zip");
+	system("unzip fasta_genomes.zip");
+	system("unzip genomes.zip");
+	unlink("fasta_genomes.zip");
+	unlink("genomes.zip");
+	open(LS,"ls *gff |");
+	while(my $line = <LS>){
+		chomp($line);
+		my $concat = "$zip.genomeszip/".$line;
+		if ($line =~/(.*)\.gff/){
+			my $name = $1;
+			if ($concat =~/\w+/){
+				$data{"input_genomes"}{"$name"}{"gff3"} = "$concat";
+				$data{"input_genomes"}{"$name"}{"name"} = "$name";
+			}
+		}
+	}
+	close(LS);
+
+	open(LS,"ls *fasta |");
+        while(my $line = <LS>){
+                chomp($line);
+                my $concat = "$zip.genomeszip/".$line;
+                if ($line =~/(.*)\.fasta/){
+                        my $name = $1;
+                        if ($concat =~/\w+/){
+				$data{"input_genomes"}{"$name"}{"fasta"} = "$concat";
+                        }
+                }
+        }
+        close(LS);
+
+}
+elsif ($zip ne "None"){
+	system("rm -rf $zip.genomeszip");
+	mkdir("$zip.genomeszip");
+	chdir("$zip.genomeszip");
+	my $head = `head -1 $zip`;
+	if ($head =~/LOCUS/){
+		push @{$data{"input_genbanks"}}, "$zip";
+	}
+	else{
+		system("cp -rf $zip ./genomes.zip");
+		system("unzip genomes.zip");
+		unlink("genomes.zip");
+		open(LS,"ls |");
+		while(my $line = <LS>){
+			chomp($line);
+			my $concat = "$zip.genomeszip/".$line;
+			if ($concat =~/\w+/){
+				push @{$data{"input_genbanks"}}, "$concat";
+			}
+		}
+		close(LS);
+	}
+}
+#else{
+#	push @{$data{"input_genbanks"}}, "";
+#}
+chdir($dir);
+
+DumpFile($out, \%data);