我组合了 2 个序列文件,所以我有 1 个文件和 2 个序列。我已将这 2 个序列拆分为一个 @char 数组,因为我稍后必须逐个字符地比较它们。然而,序列中的 1 个在两行上。我想使用 join 功能来组合 2 行,但我不知道如何。
前任:
序列 1
ACGTATATATTATATCTGGCGCTATCGATGCTATCGAT
CGATGCGCG
序列 2
AGTGAGCGTAGCTAGCGGCGCGATCTAGCTA
到目前为止我的代码
#!usr/bin/perl
use strict;
use warnings;
# open file 1
open (my $seq1, "<", "file1.fa") or die $!;
# open file 2
open (my $seq2, "<", "file2.fa") or die $!;
# open combined file
open (my $combined, ">", "combined.txt") or die $!;
# read file 1, skip header line, write to combined file
while (my $line = <$seq1>) {
if($line =~ />/) {
next;
}
else {
print $combined "$line\n";
}
}
# read file 2, skip header line, write to combined file on new line
while (my $line2 = <$seq2>) {
if ($line2 =~ />/) {
next;
}
else {
print $combined "$line2\n";
}
}
# need to open combined file for reading
open (my $combined2, "<", "combined.txt") or die $!;
# read through combined file line by line
while (my $seqs = <$combined2>) {
chomp($seqs);
# split sequences into characters
my @chars = split(//, $seqs);
# the sequence from file1 is on 2 separate lines. Need to join these
# lines together