Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I am using this code given below which you send me. I want to add some more things so that i can count GC% in 0-200, 1-201, 2-202.... upto 1000 or more and if GC% in any region is more than 50% then to take output as: "GC% in more than 50% in this ... region". How can i do this.
#! perl -slw use strict; my $dna = do{ local $/; <DATA> }; $dna =~ tr[ +\n][]d; my %counts; ++$counts{ substr $dna, $_, 1 } for 0 .. 199; for + my $offset ( 0 .. length( $dna )-200 ) { printf "range: %d .. %d A:% +d C:%d G:%d T:%d\n", $offset, $offset+1 +99, @counts{ qw[ A C G T ] } +; --$counts{ substr $dna, $offset, 1 }; ++$counts{ substr $dna, $offs +et+200, 1 }; } __DATA__ TGCCATCGCGCCAGGAGGGAAGACCAGTTGCTCTGGGTAAATCAG +CCGTGAGCGTATCTGTCCCTCTTAT +AATTAGGAGTTTAAACTCTACGATGTTACC ATCCTTGAATC +AGGTATATACCGCACTGAAACATCGTCGGCTTTGGGCTCATTCGCTACCCTGTCGCTGA +TATGCGAT +CTATTCTACATATGCGGGGCCA CCCAATGTCGATTGTCATGAGGAGGGGGTCATAACGACTCACTATA +GGACCAGCACGTCCGGTTGCGCTG +AGTAAAATAGAGCTACAAAAGACACAGTAC TCCAAGATGTAA +AGGGGAAGACGGGACCTGGGTCGGGGGCGCAACTTCACTGAGCTTTTAACCTTGCGCG +CATGCGAGA +GCCTTTCCGCTTAGGAAATGC TGTAAGATCAAGTGGTAGGACTATTGAGAGGTCTTACCTTGCCGCAG +CAACGTGGACGGCGACCGGATAA +TTTAAGGCCGACATTCAATATAGAATGTCA GGGAGCAGAACTG +TATCCCAAATGCTAGTTGTAGGTGTACGAGCGCACCTGGGGACCTATCGCTCCGACG +GGGTCTGCGT +AGCCCATACATCCTGCCAGC ACTGGGGCTATTGAACGGTCAATCCGTAATGTACTCGCTGAATGCTCA +GGGATTCCTTAATCTTTGAGCA +CGCGGCTTCTCTCACTTTTCTCACGTCAAC CCTGACTCATAACG +GAGTTCGGCAGTCCCGGAACGGCTTATAGAAGCAATGCCTGAGTAGATAGCGTCAG +GGATCGGCCCT +ACGTCGAGTCCAGTACGCC ATTGGATGGAGGTCTCAGCCGTCGGTGGAGTGCGGCTCCACCCCCACAT +GAACGAGGTTGTTCCTGACCA +CCCCTGAAACTGTGAGAACCATTGTGTCGA AACCAAGAGGCTTGC +GTCGCGCTATAGGTCGATTGCCCCCTAGTTTCCCTATATTGAACGTGTTTCCATT +AAAGACTCTCGG +TAAATCTCACGTATTGCA
Produces:
C:\test>junk77 range: 0 .. 199 A:46 C:51 G:47 T:56 range: 1 .. 200 A:4 +6 C:52 G:47 T:55 range: 2 .. 201 A:46 C:53 G:46 T:55 range: 3 .. 202 +A:46 C:53 G:46 T:55 range: 4 .. 203 A:47 C:52 G:46 T:55 range: 5 .. 2 +04 A:47 C:52 G:46 T:55 range: 6 .. 205 A:47 C:52 G:46 T:55 range: 7 . +. 206 A:47 C:51 G:47 T:55 range: 8 .. 207 A:47 C:51 G:46 T:56 range: +9 .. 208 A:47 C:51 G:46 T:56 range: 10 .. 209 A:47 C:51 G:46 T:56 ran +ge: 11 .. 210 A:48 C:50 G:46 T:56 range: 12 .. 211 A:48 C:49 G:46 T:5 +7 range: 13 .. 212 A:47 C:49 G:46 T:58 range: 14 .. 213 A:47 C:49 G:4 +6 T:58 range: 15 .. 214 A:47 C:49 G:45 T:59 range: 16 .. 215 A:46 C:5 +0 G:45 T:59 range: 17 .. 216 A:47 C:50 G:44 T:59 ...

In reply to Re^8: how to access elements in perl by grewal7634
in thread how to access elements in perl by grewal7634

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-04-23 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found