You dont explain very well what you want. What do you mean by gene for instance
I think this does most of what you are after. but it is a memory hog.
use strict; use warnings; my @genes; my %genes_found; my $genesFn = "Genes_list.txt"; open my $genesFh, "<", $genesFn or die "could not open genes file hand +le $!\n"; while (my $gene=<$genesFh>) { chomp $gene; push @genes, $gene; } my $an_fn='annotation_files_path.txt'; open my $an,'<',$an_fn or die "cant open $an_fn $!"; while (my $annotationsFn =<$an>){ chomp $annotationsFn ; open my $gff,'<',$annotationsFn or die "cant open $annotationsFn $! +"; while (my $gff_line =<$gff>){ chomp $gff_line; for my $gene (@genes) { if (index($gff_line,$gene) != -1) { $genes_found{$gene}{$annotationsFn}=[] unless (defined ($genes +_found{$gene}{$annotationsFn})); push @{$genes_found{$gene}{$annotationsFn}},$gff_line; } # index } # gene } # gff_line close $gff; } # my $annotationsFn close $an; for my $gene (@genes) { unless ($genes_found{$gene}) { print "gene $gene not found \n";} else { my $resultsFn='result-gene-'.$gene.'.txt'; open my $resultsFh, ">", $resultsFn or die "could not open handle +to results file $!\n"; for my $annotationsFn (sort keys (%{$genes_found{$gene}})) { print $resultsFh 'from:'.$annotationsFn."\n"; for my $found (@{$genes_found{$gene}{$annotationsFn}}){ print $resultsFh 'line:'.$found."\n"; } # found } #$annotationsFn close $resultsFh; } # else } # gene
In reply to Re: perl script for extracting gene information from gff file
by huck
in thread perl script for extracting gene information from gff file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |