in reply to create an one-line format for this

Hi,

this would be my approach based on that what you wrote:

#!/usr/bin/env perl use strict; use warnings; my $filename = 'file'; open my $fh, "<", $filename or die $!; local $/ = "//\n"; while(defined(my $line = <$fh>)) { chomp $line; my ($seq_length, $ID, $top, $seq); foreach my $part (split /\n/, $line) { if($part =~ /^(\d+)\s+(.*)$/) { $seq_length = $1; $ID = $2; next; } if($part =~ /^([S\.]+)$/) { $top .= $1; next; } $seq .= $part; } print ">$ID\n$seq\n$top\n"; } close $fh;

Best regards
McA

Replies are listed 'Best First'.
Re^2: create an one-line format for this
by Anonymous Monk on Oct 01, 2013 at 22:55 UTC
    Thank you very much for your help!