-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmake_conf_file.pl
More file actions
executable file
·115 lines (97 loc) · 2.77 KB
/
make_conf_file.pl
File metadata and controls
executable file
·115 lines (97 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env perl
use strict;
use Getopt::Long;
use Cwd 'abs_path';
use Cwd 'cwd';
use warnings;
my ($out_dir, $in_dir, $help, $aro_loc, $go_loc);
GetOptions("dir|d=s"=>\$in_dir, "out|o=s"=>\$out_dir, "help|h|?"=>\$help, "aro|a=s"=>\$aro_loc, "go|g=s"=>\$go_loc);
if ($help || !($in_dir) || !(-d $in_dir))
{
print STDERR "Runs MASH of a directory or fasta file against the MASH sketch\n\n";
print STDERR "--------------------USAGE--------------------------------------\n";
print STDERR " -d input pangenome directory\n";
print STDERR " -o output directory\n";
print STDERR " -g location of go term obo file. Default is input directory\n";
print STDERR " -a location of aro obo file. Default is input directory\n";
print STDERR " -h help\n";
exit(0);
}
my @cwd = split "\/", abs_path($0);
my $src_dir = ""; for (my $i = 0; $i < scalar(@cwd)-1; $i++) { $src_dir .= $cwd[$i] . "/"; }
$in_dir = abs_path($in_dir);
my $num =2;
my @obo_files = ("DIR/aro.obo", "DIR/gene_ontology.1_2.obo");
my @types = ("AROTerms", "GOTerms");
my @map_files = ("DIR/aro_centroid.list.txt", "DIR/results/centroids.mapterm.txt");
my @color = ("ff0000", "CURR/cluster_colors.txt");
my @names = ("Antibiotic Resistance", "DIR/results/centroids.cluster_roles.txt");
$names[1] =~ s/DIR/$in_dir/g;
if (!-e $names[1])
{
$names[1] = "DIR/centroids.cluster_roles.txt";
}
$map_files[1] =~ s/DIR/$in_dir/g;
if (!-e $map_files[1])
{
$map_files[1] = "DIR/centroids.mapterm.txt";
print STDERR "Here\n";
}
if ($aro_loc)
{
if (-e $aro_loc)
{
$obo_files[0] = $aro_loc;
}
else
{
print STDERR "Cannot find aro obo file. Defaulting to input directory...";
}
}
if ($go_loc)
{
if (-e $go_loc)
{
$obo_files[1] = $go_loc;
}
else
{
print STDERR "Cannot find aro obo file. Defaulting to input directory...";
}
}
if (!$out_dir)
{
$out_dir = cwd();
}
if (!-e $out_dir)
{
print STDERR "Cannot find directory. Quiting...\n\n\n"; exit();
}
if (-e "$out_dir/func_file.conf.txt")
{
print STDERR "Functional file already exists... overwriting...\n";
}
open(OUT, ">", "$out_dir/func_file.conf.txt");
for (my $i = 0; $i < $num; $i++)
{
if ($obo_files[$i] && $types[$i] && $map_files[$i] && $color[$i] && $names[$i] )
{
printf OUT "START\n";
$types[$i] =~ s/DIR/$in_dir/g;
$types[$i] =~ s/CURR/$src_dir/g;
printf(OUT "ID\t%s\n",$types[$i]);
$map_files[$i] =~ s/DIR/$in_dir/g;
$map_files[$i] =~ s/CURR/$src_dir/g;
printf(OUT "mapfile\t%s\n",$map_files[$i]);
$obo_files[$i] =~ s/DIR/$in_dir/g;
$obo_files[$i] =~ s/CURR/$src_dir/g;
printf(OUT "ontology\t%s\n",$obo_files[$i]);
$names[$i] =~ s/DIR/$in_dir/g;
$names[$i] =~ s/CURR/$src_dir/g;
printf(OUT "name\t%s\n",$names[$i]);
$color[$i] =~ s/DIR/$in_dir/g;
$color[$i] =~ s/CURR/$src_dir/g;
printf(OUT "color\t%s\n",$color[$i]);
printf(OUT "END\n\n")
}
}