forked from andreiaamaral/IsomiR-Window
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Species.pl
46 lines (32 loc) · 1016 Bytes
/
Species.pl
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
package Species;
use strict;
use warnings;
sub species_to_column {
# Recieves a species scientific name and a column description and returns that column's value for the species
# ex.: species_to_column("Sus_scrofa", "genome_assembly") returns "Sscrofa11.1"
my ($species, $column) = (@_);
my %column_number = (
"miRDeep2_name" => 1,
"genome_assembly" => 2,
"miRBase_code" => 3,
"taxon_ID" => 4,
"topGO_mapping" => 5,
"SNPs_database" => 6,
"kingdom" => 7,
);
# Open the file with the Species information
my $file = "species_hash.txt";
open(INFO, '<', $file) or die "Could not open $file: $!";
my $header_to_skip = <INFO>; #skips the header
my %hash_of_species;
# Assign the species cientific name (row[0]) as a key to the column value
foreach my $line (<INFO>) {
chomp $line;
my @row = split(";", $line);
my $wanted_column = $column_number{$column};
$hash_of_species{$row[0]} = $row[$wanted_column];
}
close(INFO);
return $species = $hash_of_species{$species};
}
1;