1

I am sorry ton ask this kind of stupid question but I could not find it by myself... I learned perl a while ago and I am a little lost.

I want to convert this kind of output :

Palindromes of:  seq1 
Sequence length is: 24 
Start at position: 1
End at position: 24
Minimum length of Palindromes is: 6 
Maximum length of Palindromes is: 12 
Maximum gap between elements is: 6 
Number of mismatches allowed in Palindrome: 0



Palindromes:
1        aaaaaaaaaaa       11
         |||||||||||
24       ttttttttttt       14




Palindromes of:  seq2 
Sequence length is: 15 
Start at position: 1
End at position: 15
Minimum length of Palindromes is: 6 
Maximum length of Palindromes is: 12 
Maximum gap between elements is: 6 
Number of mismatches allowed in Palindrome: 0



Palindromes:
1        aaaaaac        7
         |||||||
15       ttttttg        9

Into a gff or bed file :

seq1  1   24
seq2  1   15

I found a perl module to do it : https://metacpan.org/pod/Bio::Tools::GFF

This is my little script :

#!/usr/bin/perl
use strict;
use warnings 'all';
use Bio::Tools::EMBOSS::Palindrome;
use Bio::Tools::GFF;

my $filename = "truc.pal";
# a simple script to turn palindrome output into GFF3

my $parser = Bio::Tools::EMBOSS::Palindrome->new(-file => $filename);
my $out    = Bio::Tools::GFF->new(-gff_version => 3,
                                 -file => ">$filename.gff");
while( my $seq = $parser->next_seq ) {
   for my $feat ( $seq->get_SeqFeatures ) {
      $out->write_feature($feat);
   }
}

This is the result :

##gff-version 3
seq1       palindrome      similarity      14      24      .       -       1       allowed_mismatches=0;end=24;maximum gap=6;maximum_length=12;minimum_length=6;seqlength=24;start=1
seq2       palindrome      similarity      9       15      .       -       1       allowed_mismatches=0;end=15;maximum gap=6;maximum_length=12;minimum_length=6;seqlength=15;start=1

The issue is : I want to have it the result the start and the end of the palindrome and the specific position in the last line.

Exemple of what I want:

##gff-version 3
seq1       palindrome      similarity      1      24      .       -       1       mismatches=0;gap_positions=11-14;gap_size=3
seq2       palindrome      similarity      1      15      .       -       1       mismatches=0;gap_positions=7-9;gap_size=2

Thank you in advance.

Papaya
  • 107
  • 9
  • 1
    *"But I could not use it..."* That's not a very useful description of the problems you've had. Could you please [edit your question](https://stackoverflow.com/posts/59029949/edit) and expand on that? What have you tried? What unexpected behaviour have you seen? Please show us your code. – Dave Cross Nov 25 '19 at 11:10

0 Answers0