Last active
April 13, 2019 02:27
-
-
Save laurianesimon/0ae2dd7b8c34c23cdacec217aeaab79c to your computer and use it in GitHub Desktop.
5S RNA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
if | |
(($ARGV[0] eq "-h") || ($ARGV[0] eq "--h") || ($ARGV[0] eq | |
"- | |
help" | |
)|| ($ARGV[0] eq "--help")|| (!defined($ARGV[3]))) | |
{ | |
"# Obtaining reads covering a part of the reference | |
sequence | |
# Argument | |
0 : reference | |
# Argument | |
1 : path to the fasta files for reads mapped on | |
the | |
reference | |
# Argument | |
2 : beginning of comparaison | |
# Argument | |
3 : end comparaison | |
# Argument | |
4 : end of the position | |
# Argument | |
5 : beginning of position | |
# Argument | |
6 : % of difference\n"; | |
die("\n"); | |
} | |
my | |
%hash_nuc_ref; | |
open(F1,"$ARGV[0]") | |
or die ("ARG fichier $ARGV[0] "); # Obtaining | |
the | |
positions of interest of the reference | |
while(my | |
$ligne= <F1>){ | |
chomp($ligne); | |
my | |
$position; | |
if | |
(!($ligne=~/^>/)) { | |
my | |
@split_seq= split ("",$ligne); | |
for(my $i=0;$i<scalar(@split_seq);$i++){ | |
$hash_nuc_ref{$i}=$split_seq[$i]; | |
} | |
} | |
} | |
close F1; | |
my | |
%hash_motif_sans_mut; | |
my | |
%hash_motif; | |
my | |
$position; | |
open(F1,"$ARGV[1]") | |
or die ("ARG fichier $ARGV[0] "); #Reading of | |
the file | |
containing the reads mapped on the zone of interest | |
while(my | |
$ligne= <F1>){ | |
chomp($ligne); | |
my | |
$nom_seq; | |
if ($ligne=~/^>/) { | |
$nom_seq=$ligne; | |
my | |
@split_info_seq= split('\s',"$ligne"); | |
$position = | |
$split_info_seq[1]; | |
$position=~ | |
s/pos=//; | |
} | |
else{ | |
if($ARGV[2] | |
>= $position ){ | |
my | |
$limit=$ARGV[3]-$position; | |
my | |
$compte_mutation=0; | |
my | |
@split_info_seq= split("","$ligne"); | |
my | |
$i=$ARGV[2]-$position; | |
for( | |
$i;$i<=$limit;$i++){ | |
my | |
$temp=$position+$i-1; | |
if | |
($split_info_seq[$i] ne | |
$hash_nuc_ref{$temp}){ | |
$compte_mutation++; | |
} | |
} | |
if(( | |
$compte_mutation <= $ARGV[6])){ | |
my | |
$longeur= $ARGV[4]-$ARGV[5]; | |
my $start | |
=$ARGV[5]-$position; | |
my $coupe = | |
substr($ligne,$start, | |
$longeur); | |
$hash_motif{$coupe} | |
{$compte_mutation}++; | |
} | |
} | |
} | |
} | |
close F1; | |
my | |
$longueur_a_reagarder = $ARGV[4]-$ARGV[5]; | |
close F1; | |
my | |
%hash_fichier; | |
open(F1 | |
,">>motif_clef_$ARGV[1]\_$ARGV[5]\_$ARGV[4]") ; # | |
Extraction | |
of the motifs adjacent to the interest zone of the | |
reference | |
foreach my | |
$clef (keys(%hash_motif)){ | |
foreach(keys | |
%{$hash_motif{$clef}}){ | |
my | |
$longeur_clef = length($clef); | |
if | |
($longeur_clef == $longueur_a_reagarder){ | |
print F1 | |
"$clef\t$hash_motif{$clef}{$_}\t$_\n"; | |
} | |
} | |
} | |
`sort -k2nr | |
motif_clef_$ARGV[1]\_$ARGV[5]\_$ARGV[4] > | |
motif_clef_$ARGV[1]\_$ARGV[5]\_$ARGV[4]_sorted`; | |
# Sorting motifs by | |
descending order | |
`rm | |
motif_clef_$ARGV[1]\_$ARGV[5]\_$ARGV[4]`; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
when I run this perl script, the following error occurred, would you tell me how to deal with them? or tell me in detailed how to configure this script parameters. Thanks
perl ../../../bin/T-stretch-extraction.pl
syntax error at ../../../bin/T-stretch-extraction.pl line 59, near "){"
Global symbol "$ligne" requires explicit package name at ../../../bin/T-stretch-extraction.pl line 61.
syntax error at ../../../bin/T-stretch-extraction.pl line 80, near "}"
syntax error at ../../../bin/T-stretch-extraction.pl line 100, near "){"
syntax error at ../../../bin/T-stretch-extraction.pl line 180, near "}"
syntax error at ../../../bin/T-stretch-extraction.pl line 201, near "$clef ("
Global symbol "$clef" requires explicit package name at ../../../bin/T-stretch-extraction.pl line 204.
syntax error at ../../../bin/T-stretch-extraction.pl line 217, near "}"
Execution of ../../../bin/T-stretch-extraction.pl aborted due to compilation errors.