comparison SMART/bacteriaRegulatoryRegion_Detection/colorGff.pl @ 18:94ab73e8a190

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents
children
comparison
equal deleted inserted replaced
17:b0e8584489e6 18:94ab73e8a190
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 parse DOOR repport file and write information in gff3 format.
23
24 -i|--input fileName gff input file name
25 -c|--color RGBcode RGB code for color
26 -o|--output fileName gff3 output file name
27 [-h|--help] help mode then die
28
29 =head1 AUTHOR - Claire Toffano-Nioche - jan.11
30
31 =cut
32 #-----------------------
33 my ($fileName, $colourGff, $outFileName) = ("", "", "colorOut.gff3") ;
34 # command line check
35 foreach my $num (0 .. $#ARGV) {
36 SWITCH: for ($ARGV[$num]) {
37 /--input|-i/ && do {
38 $fileName=$ARGV[$num+1];
39 open ( fichierGff, "< $fileName" ) or die "Can't open gff file: \"$fileName\"\n" ;
40 last };
41 /--color|-c/ && do {
42 $colourGff =$ARGV[$num+1]." ".$ARGV[$num+2]." ".$ARGV[$num+3];
43 last };
44 # /--output|-o/ && do {
45 # $outFileName=$ARGV[$num+1];
46 # last };
47 /--help|-h/ && do { exec("pod2text $0\n") ; die };
48 }
49 }
50 # open(OUT,">$outFileName") or die "Error can't $outFileName open for output. $!\n";
51 # informations retrieval
52 my @lines = <fichierGff> ;
53 close fichierGff ;
54 # treatment
55 #print "gff file read ; number of lines : $#lines\n";
56 for (my $i=0 ; $i <= $#lines ; $i++) {
57 if ($lines[$i] =~ /;/) {
58 if ($lines[$i] =~ /color=/) {
59 $lines[$i] =~ s/color=.*;/color=$colourGff;/ ;
60 } else { # add colour
61 $lines[$i] =~ s/;/;color=$colourGff;/ ;
62 }
63 } else { # (no = gff bug if col9 begin with semi-coma ?) or only one tag : add color tag
64 chomp($lines[$i]) ;
65 $lines[$i] .= "; color=".$colourGff.";\n";
66 }
67 # print OUT $lines[$i] ;
68 print $lines[$i];
69 }
70 # close OUT ;
71 exit(0);