i NEED A PERL SCRIPT TO CREATE NAME_DIRECTORY FOR ALL TRAJECTORIES.

i've trajectory files like this,

rep2.tra3M.bz2
rep2.tra4M.bz2
rep2.tra5M.bz2
rep2.tra6M.bz2
rep2.tra7M.bz2

i want a scipt to list all replicas,copy zipped replicas and unzip all replicas and create a file with list of replicas and call make_pdb.pl for all trajectories.

Recommended Answers

All 6 Replies

Do you have a specific question on how to do this, or are you just asking someone to write the script for you?

im asking how to do this, as im new to perl if anyone can help me with the script i would be very thankful.

i NEED A PERL SCRIPT TO CREATE NAME_DIRECTORY FOR ALL TRAJECTORIES.

i've trajectory files like this,

rep2.tra3M.bz2
rep2.tra4M.bz2
rep2.tra5M.bz2
rep2.tra6M.bz2
rep2.tra7M.bz2

i want a scipt to list all replicas,copy zipped replicas and unzip all replicas and create a file with list of replicas and call make_pdb.pl for all trajectories.

What do you mean by 'replica'? Assuming that replicas are files whose names start with 'rep' and you know in what directory they are located, you could list all the replicas like this:

#!/usr/bin/perl
use strict;
use warnings;
use 5.010;

my @replicas = glob('/home/david/data/rep*.*');
say "List of replicas:";
say join("\n", @replicas);

If you're new to Perl but familiar with UNIX, sometimes it's easier to use Perl like a shell language until you learn the internal functions and available modules more. This is how I started with Perl.

For example, there is a Perl module available to manipulate bzipped files, but you might be more comfortable with using the system binary. Using d5e5's code above, you could complete one of your requirements using a system call to bzip itself:

foreach my $rep (@replicas) {
     system("bunzip2", "$rep");
}

If you need more help, give us some more details about what 'replica' files are, what filenames to expect in the bzipped files, and what you want to have happen to the files.

commented: Good tip for getting started. +8

Thanks a lot for the information. i meant replicas as my trajectory files which has coordinate files inside. im trying to upzip the files and chang them to pdb files.

Thanks a lot for the information. i meant replicas as my trajectory files which has coordinate files inside. im trying to upzip the files and chang them to pdb files.

I don't know bioinformatics so am not familiar with the terminology you use when referring to the different kinds of files.

What I think you want to do is start by making an array (a variable containing a list of trajectory file names) using the glob command like in my example script. Then you want to make a new directory for each of the trajectory files (a trajectory file is a zipped archive of coordinate files, right?) and then unzip the trajectory file into the new directory. (Make a new directory named 'rep2.tra3M.bz2' and unzip the rep2.tra3M.bz2 file so that all its coordinate files go into the rep2.tra3M.bz2 directory.)

After unzipping all the trajectory files into new directories you want to write a script that uses the glob command to build an array of the coordinate file names in each directory. Then you can loop through this array and perform a subroutine or whatever for each file name in the array to transform the data in the coordinate file into data that you want to write to a pdb file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.