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

Re^2: counter of files? something else?

by Random_Walk (Prior)
on Apr 23, 2015 at 13:29 UTC ( [id://1124394]=note: print w/replies, xml ) Need Help??


in reply to Re: counter of files? something else?
in thread counter of files? something else?

I am not sure why you are worried so much about counting files. If you have an array of files, perl will happily skip though them, one at a time, in order, using for. There is lots of stuff here though, that is not accounted for. You are not opening any files to read, $atomcount is a mystery. And the @atom array (probably better used at $atom[$p]) is also unmentioned before now.

But anyway, here is a go at wrangling your code a little. It probably won't compile, but may give you some useful hints. If you can post a more complete listing of your code, we may be able to help more

my @files = qw(file01 file02 file03 file04 file05); my $carboxyl = 0; # you may want to start at 1 instead for my $filename (@files) { open my $pdb, '>', "$filename.pdb"; my ($p, $w); my $bx = 50; # Never used again ? my $by = 50; # Never used again ? my $bz = 50; # Never used again ? print $pdb "\t%filename\n"; printf $pdb "%5d\n", $atomcount; for my $p (1 .. $atomcount) { # Perl likes to help printf $pdb "%5d%-5s%5s%5d%8.3f%8.3f%8.3f\n", 1,$carboxyl,@atom[$ +p],$p,@x[$p],@y[$p],@z[$p]; } $carboxyl++; printf $pdb "%10.5f%10.5f%10.5f\n",$bx,$by,$bz; close $pdb; }

Update

is 'pdb' http://en.wikipedia.org/wiki/Protein_Data_Bank_(file_format) ?

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Replies are listed 'Best First'.
Re^3: counter of files? something else?
by fasoli (Beadle) on Apr 23, 2015 at 13:49 UTC

    I want the files counted as I think of it as the only way to get different $carboxyl entries. All I want is just a number, from 1 to whatever, next to my $carboxyl entry, so that I will be able to tell the files apart.

    This number doesn't have to be associated with the files, it doesn't have to be a file counter, it just has to be consecutive and different every time, for each of the resulting pdb files.

    It's just because I'm a newbie that I thought that associating my goal with a file counter would make more sense and would be easier to implement.

    $atomcount and @atom aren't unaccounted for, they're just further up in my script (sorry about that, I didn't know how to include a concise part without copying the whole thing). Also, I'm opening the pdb files and printing coordinates (x,y,z) in them, from the files that are already open (again, opened further up in my script and these are the files of the foreach loop)

    Thank you (all) for you help. I'll try your suggestions and update you, hopefully I'll get it right - at least in my mind or on paper.

    Update: Yes, pdb is protein data bank files. Although I'm an idiot and instead of pdb it should read gro, as I changed to gro files (and thus the format is wrong for pdb files). I'm really sorry about that, thankfully it doesn't change my question though so not a disaster (I'm embarrassed)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1124394]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 15:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found