-
Notifications
You must be signed in to change notification settings - Fork 49
/
sanity_check_mature_ref.pl
executable file
·61 lines (49 loc) · 1.26 KB
/
sanity_check_mature_ref.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/perl -W
use strict;
my $counter=0;
my %hash_num;
my $id;
my $hint="Please check your file for the following issues:\n
I. Sequences are allowed only to comprise characters [ACGTNacgtn].
II. Identifiers are not allowed to have withespaces.\n";
while(<>){
$counter++;
if(/^\>(.+)$/){
$id=$1;
if($id =~ /\s+/){
die "Error in line ",Nicenumber($counter),": The identifier\n
$id\n
contains white spaces\n
$hint
You could run remove_white_space_in_id.pl inputfile > newfile
This will remove everything from the id line after the first whitespace
";
}else{
$hash_num{$id}++;
}
}elsif(not /^([A|C|G|T|U|N|a|c|g|t|u|n]+)$/){
die "Error in line ",Nicenumber($counter),": The sequence\n
$_\n
contains characters others than [acgtunACGTUN]\n
$hint
";
}
}
exit;
## subroutine to insert each 3 digits a dot
sub Nicenumber{
my @numarr=split(/[.,]/,shift);
my $number = $numarr[0];
my @n = split(//,reverse($number));
my $res="";
for(my $j=0; $j < length($number); $j++){
if($j%3 eq 0 and $j ne 0){
$res.=".$n[$j]";
}else{
$res.="$n[$j]";
}
}
$res=reverse($res);
$res.=",$numarr[1]" if($numarr[1]);
return($res);
}