Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
What could
$domchain =~/\S/g; $pdbchain =~/\S/g; chomp($domchain); chomp($pdbchain);
possibly accomplish?

I tried to fix some things in the code below, but, naturally, I could't try to run it (as I don't have the files).

use strict; use warnings FATAL => 'all'; use autodie; my $dir = "<my directory>"; my ( $dom_file_name, $csa_file_name ) = @ARGV; my %csa_hash; my %dom_hash; open my $csa_file, '<', $csa_file_name; while ( my $csa = <$csa_file> ) { my @csa_data = split( /\,/, $csa ); $csa_hash{ $csa_data[0] . $csa_data[3] } = $csa_data[4]; } close($csa_file); open my $dom_file, '<', $dom_file_name; while ( my $dom = <$dom_file> ) { my @dom_data = split /\s+/, $dom; my $domain = $dom_data[0]; next if exists $dom_hash{$domain}; open my $ind_dom_file, '<', $dir . $domain; while ( my $line = <$ind_dom_file> ) { chomp $line; my @ff = split /\s+/, $line; my $number = $ff[5]; my $CA = $ff[2]; push @{ $dom_hash{$domain} }, $number if $CA eq 'CA'; } close $ind_dom_file; } close $dom_file; while ( my ( $protein_dom, $residues_ref ) = each %dom_hash ) { for my $residue ( @{$residues_ref} ) { my $dom_chain = substr( $protein_dom, 0, 5 ); if ( $residue eq $csa_hash{$dom_chain} ) { print "$dom_chain $residue\n"; } } }

The idea was that it does the same thing as your code, but faster.


In reply to Re: Why is my program so slow even though I've used hashes? by akho
in thread Why is my program so slow even though I've used hashes? by Angharad

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 surveying the Monastery: (4)
As of 2024-04-26 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found