in reply to combine 2 fasta files into 1

It look like the F1 file has HTML in it and a <br> looks like a new line but it is not,
is just for formatting when you look at it with a browser like Internet Explorer.

Replies are listed 'Best First'.
Re^2: combine 2 fasta files into 1
by Generoso (Prior) on Jul 30, 2010 at 21:34 UTC

    Maybe this is what you are looking for.

    use warnings; use strict; open( F1, "subsettest.txt" ) or die "file1: $!"; open( F2, "subsettest1.txt" ) or die "file2: $!"; while ( my $s1 = <F1> ) { my $s2 = <F2>; if ( $s1 =~ /^>/ ) { print $s1; } else { print $s2,$s1; } } close F1; close F2; exit;
    >GK9PVB108JH8SN rank=0000021 x=3781.0 y=885.0 length=137 40 38 38 30 30 30 38 40 40 30 30 30 36 40 40 40 40 40 40 40 40 40 40 4 +0 39 34 34 14 14 14 14 13 19 14 18 25 32 32 34 27 TGATTATGAGTTAGATGTTCGCTCTGAGGTTTCAACGATGCTTCAAGATTCCTAATTCGCGTTGCGACTC +TCGAGTATGCGTTCTATTCACATTTCTGTTGTCGTACATATTTGACTCACGATCTTGATTTCTTATC >GK9PVB108JYDQ5 rank=0000032 x=3965.0 y=143.0 length=53 25 21 21 23 23 37 31 31 31 37 37 39 38 40 40 40 40 40 40 40 40 39 39 3 +9 39 35 23 25 25 37 34 35 36 37 37 37 37 37 39 39 40 40 40 40 39 38 3 +5 33 33 33 32 31 19 GTTTTCAACGCTGGTTCGAGATTTCCTAATTTCACATTGCGACTCTCGAGTGC
      Thanks for your suggestion but removing the chomp function of my script doesn't solve my problem. It is still giving output that looks like this:
      >GK9PVB108JRQBH rank=0000011 x=3889.0 y=1131.0 length=82 TCCATGTGTACAACTCATATGGAGCATCGATAGTATTAACAGTCTTGGTTGTGCGAGTTC 19 19 19 32 32 32 32 23 23 15 15 15 19 19 24 30 29 30 30 27 19 19 20 3 +0 35 35 33 31 31 31 31 32 32 30 23 16 15 15 15 24 28 28 25 22 17 17 1 +7 17 23 21 21 21 24 28 24 19 18 17 16 19 TTTGTTGTTTCCTTTAACTAAC
      instead of:
      >GK9PVB108JRQBH rank=0000011 x=3889.0 y=1131.0 length=82 TCCATGTGTACAACTCATATGGAGCATCGATAGTATTAACAGTCTTGGTTGTGCGAGTTCTTTGTTGTTT +CCTTTAACTAAC 19 19 19 32 32 32 32 23 23 15 15 15 19 19 24 30 29 30 30 27 19 19 20 3 +0 35 35 33 31 31 31 31 32 32 30 23 16 15 15 15 24 28 28 25 22 17 17 1 +7 17 23 21 21 21 24 28 24 19 18 17 16 19

      Ok form what I figure you have several lines in F1 and you what to skip the first corresponding line in F2.

      use warnings; use strict; open( F1, "subsettest.txt" ) or die "file1: $!"; open( F2, "subsettest1.txt" ) or die "file2: $!"; my @s2s = (); while ( my $s1 = <F1> ) { my $s2 = <F2>; if ( $s1 =~ /^>/ ) { foreach (@s2s) {print $_;} print $s1; @s2s = (); } else { push (@s2s,$s2); print $s1; } } foreach (@s2s) {print $_;} close F1; close F2; exit;