#!/usr/bin/perl #################################### # # AnalyzeElandFiles.pl -i input-path with Eland files (*.eland) # # reads Eland-files line by line # count number of line = number of hits # get value of column nr.11 = scaffold name ##################################### use diagnostics; use strict; use Carp; use FileHandle; use File::Path; use File::Basename; use Getopt::Std; my @peakline = (); my @temp = (); my @score = (); my @peakfile = (); my $peakfile = ""; my $FILE = FileHandle->new(); my $seq = ""; my $num = 0; my $i; my $outfile = ""; my $contigname = ""; my $j; my $seqname = ""; my $peaklinenumber = 0; my $linesread = 0; my $inputdir = ""; $| = 1; #print immediately use vars qw( $opt_i ); # Command line parsing # getopts('i:'); # # Handle missing / at path end: # if ($opt_i=~/\/$/) {$opt_i=$opt_i} else {$opt_i=$opt_i."/"} print "Reading input directory: ".$opt_i."\n"; print "scaffold\thits\n"; $inputdir = "$opt_i"."\*\.eland"; @peakfile = glob($inputdir); foreach $peakfile (@peakfile) { # # Read input file and write each line in an array cell # $linesread=0; @peakline = (); open($FILE,$peakfile) || croak(sprintf("Cannot open file \"%s\"",$peakfile)); while ( <$FILE> ) { chomp; push(@peakline,$_); $linesread++; } close($FILE) || croak(sprintf("Cannot close open file \"%s\"",$peakfile)); # # Loop through array # $peaklinenumber=0; @temp = (); $i = 0; for $i (0 .. $#peakline) { $peaklinenumber++; @temp = (); @temp=split('\t',$peakline[$i]); } print "$temp[11]\t$peaklinenumber\n"; }