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

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SMART/bacteriaRegulatoryRegion_Detection/colorGff.pl	Mon Apr 29 03:20:15 2013 -0400
@@ -0,0 +1,71 @@
+#!/usr/bin/perl -w
+###
+# But : ajout ou modif de couleur d'un gff
+# 
+# Entrees : fichier gff
+#
+# Sortie : gff affiche a l'ecran
+#
+###------------------------------------------------------
+use vars qw($USAGE);                      
+use strict;                               
+
+=head1 NAME
+
+colorGff.pl - add or change color of a gff file
+
+=head1 SYNOPSIS
+
+% colorGff.pl -i file.gff -c color [-h] 
+
+=head1 DESCRIPTION
+This script will parse DOOR repport file and write information in gff3 format.
+
+    -i|--input fileName  gff input file name
+    -c|--color RGBcode   RGB code for color
+    -o|--output fileName gff3 output file name
+   [-h|--help]           help mode then die                              
+
+=head1 AUTHOR - Claire Toffano-Nioche - jan.11
+
+=cut
+#-----------------------
+my ($fileName, $colourGff, $outFileName) = ("", "", "colorOut.gff3") ;
+   # command line check
+    foreach my $num (0 .. $#ARGV) {
+        SWITCH: for ($ARGV[$num]) {
+        /--input|-i/ && do { 
+		$fileName=$ARGV[$num+1]; 
+		open ( fichierGff, "< $fileName" ) or die "Can't open gff file: \"$fileName\"\n" ; 
+		last };
+        /--color|-c/ && do {
+		$colourGff =$ARGV[$num+1]." ".$ARGV[$num+2]." ".$ARGV[$num+3];
+		last };
+#	    /--output|-o/ && do { 
+#		$outFileName=$ARGV[$num+1]; 
+#		last };
+        /--help|-h/ && do { exec("pod2text $0\n") ; die };
+        }
+    }
+#    open(OUT,">$outFileName") or die "Error can't $outFileName open for output. $!\n";
+    # informations retrieval
+    my @lines = <fichierGff> ; 
+    close fichierGff ;
+    # treatment
+	#print "gff file read ; number of lines : $#lines\n";
+    for (my $i=0 ; $i <= $#lines ; $i++) {
+		if ($lines[$i] =~ /;/) {
+		   if ($lines[$i] =~ /color=/) {
+	    		$lines[$i] =~ s/color=.*;/color=$colourGff;/ ;
+			} else { # add colour
+	    		$lines[$i] =~ s/;/;color=$colourGff;/ ;
+	    	} 
+	    } else { # (no = gff bug if col9 begin with semi-coma ?) or only one tag : add color tag
+	    	chomp($lines[$i]) ;
+	    	$lines[$i] .= "; color=".$colourGff.";\n";
+		}
+#		print OUT $lines[$i] ;
+		print $lines[$i];
+    }
+# close OUT ;
+exit(0);