Rob Dixon wrote:
On 21/10/2011 00:32, nac wrote:
I have corrected myself a bit, I think the script is now giving me what I
want, having said that, I guess it is not the best way ( even if there is
more than one way), again any pointer are welcome.
many thanks
Nat


#!/usr/bin/perl
use strict;
use warnings;
my @seq;
@seq=qw{^TGGCAGTGGAGG ^TGTCTGGCAGTG ^TG....GCAGTG TCTGTCTG TCTGGCAG
GCAGTGGA TGTCTGGC ^TGTCTGGC ^..TCTGGCAGTG ^TGTCTGGCAGTG ^TGCATGGC};

open (IN,"</Users/nac/Desktop/example.fastq") or die
"can't open in:$!";
open
(OUT,">>//Users/nac/Desktop/example.fastq\_class_COUNTED2.txt")
or die "can't open out: $!";

It is better to use lexical filehandles, and the three-parameter form
of open, so:

open my $in, '<', '/Users/nac/Desktop/example.fastq' or die "can't open in: $!";
open my $out, '>>', '//Users/nac/Desktop/example.fastq\_class_COUNTED2.txt' or die 
"can't open out: $!";

(Is the double-slash in the output filename correct?)

my %final_hash;
        while (<IN>) {


     if (/^A|T|G|C/){

This will search for A at the start of the string, or T, G, or C
anywhere in the string, which is presumably not what you want. Also you
can save an indentation level using next:

   next unless /^(?:A|T|G|C)/;

Probably better as:

    next unless /^[ATGC]/;



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to