Mercurial > repos > clairetn > detrprok_scripts
view detrprok_scripts/colorGff.pl @ 0:a53eb951b164 draft
Uploaded
author | clairetn |
---|---|
date | Mon, 25 Mar 2013 05:39:29 -0400 |
parents | |
children |
line wrap: on
line source
#!/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 add or replace the 'color' tag of a gff formated file. -i|--input fileName gff input file name -c|--color RGBcode RGB code for color [-h|--help] help mode then die =head1 AUTHOR - Claire Toffano-Nioche - jan.11 =cut #----------------------- my ($fileName, $colorGff) = ("", "") ; # 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 { $colorGff =$ARGV[$num+1]." ".$ARGV[$num+2]." ".$ARGV[$num+3]; last }; /--help|-h/ && do { exec("pod2text $0\n") ; die }; } } # 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 (defined ($lines[$i])) { if (!($lines[$i] =~ m/^\s*$|^#/)) { # skip both null and comment lines if ($lines[$i] =~ /;/) { if ($lines[$i] =~ /color=/) { # replace value $lines[$i] =~ s/color=.*;*/color=$colorGff;/ ; } else { # add color tag and value $lines[$i] =~ s/;/;color=$colorGff;/ ; } } else { # only one tag so no coma: add color tag chomp($lines[$i]) ; $lines[$i] .= "; color=".$colorGff.";\n"; } } print $lines[$i]; } } exit(0);