0
|
1 #!/usr/bin/perl -w
|
|
2 ###
|
|
3 # But : ajout ou modif de couleur d'un gff
|
|
4 #
|
|
5 # Entrees : fichier gff
|
|
6 #
|
|
7 # Sortie : gff affiche a l'ecran
|
|
8 #
|
|
9 ###------------------------------------------------------
|
|
10 use vars qw($USAGE);
|
|
11 use strict;
|
|
12
|
|
13 =head1 NAME
|
|
14
|
|
15 colorGff.pl - add or change color of a gff file
|
|
16
|
|
17 =head1 SYNOPSIS
|
|
18
|
|
19 % colorGff.pl -i file.gff -c color [-h]
|
|
20
|
|
21 =head1 DESCRIPTION
|
|
22 This script will add or replace the 'color' tag of a gff formated file.
|
|
23
|
|
24 -i|--input fileName gff input file name
|
|
25 -c|--color RGBcode RGB code for color
|
|
26 [-h|--help] help mode then die
|
|
27
|
|
28 =head1 AUTHOR - Claire Toffano-Nioche - jan.11
|
|
29
|
|
30 =cut
|
|
31 #-----------------------
|
|
32 my ($fileName, $colorGff) = ("", "") ;
|
|
33 # command line check
|
|
34 foreach my $num (0 .. $#ARGV) {
|
|
35 SWITCH: for ($ARGV[$num]) {
|
|
36 /--input|-i/ && do {
|
|
37 $fileName=$ARGV[$num+1];
|
|
38 open ( fichierGff, "< $fileName" ) or die "Can't open gff file: \"$fileName\"\n" ;
|
|
39 last };
|
|
40 /--color|-c/ && do {
|
|
41 $colorGff =$ARGV[$num+1]." ".$ARGV[$num+2]." ".$ARGV[$num+3];
|
|
42 last };
|
|
43 /--help|-h/ && do { exec("pod2text $0\n") ; die };
|
|
44 }
|
|
45 }
|
|
46
|
|
47 # informations retrieval
|
|
48 my @lines = <fichierGff> ;
|
|
49 close fichierGff ;
|
|
50 # treatment
|
|
51 #print "gff file read ; number of lines : $#lines\n";
|
|
52 for (my $i=0 ; $i <= $#lines ; $i++) {
|
|
53 if (defined ($lines[$i])) {
|
|
54 if (!($lines[$i] =~ m/^\s*$|^#/)) { # skip both null and comment lines
|
|
55 if ($lines[$i] =~ /;/) {
|
|
56 if ($lines[$i] =~ /color=/) { # replace value
|
|
57 $lines[$i] =~ s/color=.*;*/color=$colorGff;/ ;
|
|
58 } else { # add color tag and value
|
|
59 $lines[$i] =~ s/;/;color=$colorGff;/ ;
|
|
60 }
|
|
61 } else { # only one tag so no coma: add color tag
|
|
62 chomp($lines[$i]) ;
|
|
63 $lines[$i] .= "; color=".$colorGff.";\n";
|
|
64 }
|
|
65 }
|
|
66 print $lines[$i];
|
|
67 }
|
|
68 }
|
|
69 exit(0);
|