From 37f1bc37bcec4cf9799b594d988ac254d92cae5d Mon Sep 17 00:00:00 2001 From: monsanto-pinheiro Date: Fri, 22 Nov 2019 15:39:34 +0000 Subject: [PATCH] Fix when fasta has more than one word in header Error when fasta file has more than one word, like ">chr_name description". Then the result will be "name_chr description ". This will be a problem in freec when try to find the index "GenomeCopyNumber::findIndex". miguel --- scripts/get_fasta_lengths.pl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/get_fasta_lengths.pl b/scripts/get_fasta_lengths.pl index b45ce78..740d84b 100644 --- a/scripts/get_fasta_lengths.pl +++ b/scripts/get_fasta_lengths.pl @@ -21,17 +21,19 @@ open (OUT, ">$result_file") or die "Cannot open file!!!!: $!"; $_ = ; -if (/>(.*)/) { - print OUT $1,"\t"; +if (/>(.*)/) { + my @line_splits = split /\s+/, $1; + print OUT $line_splits[0],"\t"; } my $length = 0; while () { chomp; - if (/>(.*)/) { + if (/>(.*)/) { + my @line_splits = split /\s+/, $1; print OUT $length,"\n"; $length = 0; - print OUT $1,"\t"; + print OUT $line_splits[0],"\t"; } else { $length += length($_);