[gmx-users] Error while running perl distances.pl

"가디 장데부 고라크스나트" f07338 at kist.re.kr
Mon Sep 4 04:47:36 CEST 2017

Hello Gmx user,

I would like to transport solute molecule from the ion channel (intracellular to extracellular site) using steered MD and umbrella sampling method to calculate the energy.

I followed Dr. Lemkul's tutorial and it works fine upto equilibration step but in distance.pl it shows some errors.

I used the distance of pulling along the Z-axis but still it do not work. I found when I use distance as a pull-geometry, solute moves away from the channel rather transporting through channel. Then I tried direction as a pull-geoetry, then solute transported from the chanel,and generated pullf.xvg but not pullx.xvg file.

I separated the trajectory using trjconv command

gmx_mpi_d -f recenter_traj.xtc -s md_pull.tpr -n pro-lig.ndx -o conf.gro -sep

It generated conformations.

Now I would like to calculate the COM distance between ion channel (protein) and solute (lig) using perl distance.pl but I received following error.


readline() on closed filehandle IN at distances.pl line 16

Use of uminitialized value $distance in concatanation (.) or string at distances.pl line 30.

Here is the distance.pl file which I used for this purpose which was downloaded from Dr. Lemkul's tutorial file.

#!/usr/bin/perl -w

use strict;

# loop g_dist command - measure distance in each frame, write to a file
for (my $i=0; $i<=800; $i++) {
    print "Processing configuration $i...\n";
    system("gmx distance -s md_pull.tpr -f conf${i}.gro -n index.ndx -oall dist${i}.xvg -select \'com of group \"lig\" plus com of group \"protein\"\' &>/dev/null");

# write output to single file
open(OUT, ">>summary_distances.dat");

for (my $j=0; $j<=800; $j++) {
    open(IN, "<dist${j}.xvg");
    my @array = <IN>;

    my $distance;

    foreach $_ (@array) {
        if ($_ =~ /[#@]/) {
            # do nothing, it's a comment or formatting line
        } else {
            my @line = split(" ", $_);
            $distance = $line[1];

    print OUT "$j\t$distance\n";


# clean up
print "Cleaning up...\n";

for (my $k=0; $k<=800; $k++) {
    unlink "dist${k}.xvg";



this generated the summary_distances.dat with only frame numbers but there is no distance column in the file.

Please help me to solve this issue


Dr. Changdev G. Gadhe

Post-Doc Researcher,

Convergence Research Center for Diagnosis, Treatment and Care System of Dementia,

Korea Institute of Science and Technology, 

Hwarangno 14-gil 5, Seongbuk-gu, Seoul 136-791, Korea 

Ph.: +82-10-2779-1546 , Lab: +82-02-958-6850

Email: F07338 at kist.re.kr

More information about the gromacs.org_gmx-users mailing list