Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hi Perl Monks,

I am a beginner in perl programming. I have written a perl script which can read a small text file and gives correct results for inter-substring distance in cmd in Windows XP. But cmd shows the problem of “out of memory” when I try to analyze a large text file with 219475005 letters for finding the inter-substring distance although the program counts the number of each letter in the file correctly within 2 minutes but fails to find the inter-substring distance. I think this could due to incorrect reading of file.

So I have given the initial part of the script and the results of cmd screen below. I am seeking your suggestions to rectify the mistake in the script for analyzing a large file.

Furthermore, I need the syntax at the initial part to assign the input large file to an array variable like my @lines so that I can assign this array to a scalar variable like my $string ="@lines"; for use in later part of the script.

#!/usr/bin/perl –w print "\n\nPlease type the filename: "; $DNAfilename = <STDIN>; chomp $DNAfilename; # open the large file unless ( open(DNAFILE, $DNAfilename) ) { print "Cannot open file \"$DNAfilename\"\n\n"; exit; } my @lines = <DNAFILE>; while (<DNAFILE>) { say $_; } close DNAFILE; $DNA = join( '', @lines); # Remove whitespace $DNA=~ s/\s//g; # Count number of bases $b=length($DNA); print "\nNumber of bases: $b."; # Count number of each base and nonbase $A=0;$T=0;$G=0;$C=0;$e=0; while($DNA=~ /A/ig){$A++} while($DNA=~ /T/ig){$T++} while($DNA=~ /G/ig){$G++} while($DNA=~ /C/ig){$C++} while($DNA=~ /[^ATGC]/ig){$e++} . . . .

Command Prompt Results:

C:\Documents and Settings\user\Desktop>

Please type the filename of the DNA sequence data: chr1.txt

Number of bases: 219475005.

A=63473407; T=63582431; G=45425056; C=45435903; Errors(N)=1558208.

Enter a motif to count nt between two such motifs: GAATTCCT

I found the motif!

Out of memory!

C:\Documents and Settings\user\Desktop>

Thanks to Perl Monks for their quick reply in solving perl problems.

In reply to Request to detect the mistake in a perl script for finding inter-substring distance from a large text file by supriyoch_2008

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (6)
    As of 2018-06-18 05:02 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (108 votes). Check out past polls.