Entering edit mode
6.7 years ago
ArusjakGevorgyan
▴
30
Hi everyone. I have a little problem with perl. My input file looks like this:
RAxML_result.EOG09371BVG.aa.fa.aln.phy.raxtree.test.1 IT_ine1 IM_nor1 OH_azt1 IE_sup1 IT_ras1 OD_mag1 OE_aff1
I want to take all my species and put them in my array. But my code doesn't work, I think that I'm not entering my if loop where I tell the code when it should match my specie. I will be grateful for your help.
#!/usr/bin/perl -w
use warnings;
use strict;
use 5.010;
my $comp = $ARGV[0];
if ( ! open ( FILE_HANDLE , "<" , $comp ) ) {
die "Error can't find the file: $comp because $!";}
if ( ! open ( OUT_HANDLE , ">" , $comp . ".comp.csv" ) ) {
die "Error can't make new file file: ${$comp}.comp.csv because $!";}
my @arr = ();
my $gene;
while (my $lineContent = <FILE_HANDLE> ) {
chomp $lineContent;
if ( $lineContent =~ m /^\#/){
next;
}elsif($lineContent =~ m /\.raxtree$/){
next;
}elsif($lineContent =~ m /^WARNING/){
next;
}elsif($lineContent =~ m /^f/){
next;
}else{
print "$lineContent\n";
}
foreach my $line ($lineContent){
if($line =~ m /^RAxML\_result\.(\w+)\.aa\.fa\.aln\.phy\.raxtree\.test\.\d/){
$gene="$1\n";
if($line =~ m /^(\w+)\s/){
push @arr,$1;
}
}
}
}
print $gene;
print @arr;
Hi, let me comment your code and see what exactly do you want to do:
Guessing I can suggest:
Output:
Thank you so much for your help and time.