生物分子模拟论坛

 找回密码
 我想注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 7340|回复: 0

[Perl] pl程序修改

[复制链接]
发表于 2017-2-21 16:23:24 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,下载更多分子模拟资源。

您需要 登录 才可以下载或查看,没有帐号?我想注册

x
程序如下:
#!/usr/bin/perl
##############################################################################
### SECTION:3: splits multi-MOLECULE input mol2 into individual mol2 files ###
##############################################################################

print("Splitting the multiple Ligand mol2 file into single mol2 files.\n");

#print("The single mol2 files will have the prefix: $prefix \n");
my($mol2_file) = "";
my($global_count) = 0;
my($local_count) = 0;

$mol2_file = $ARGV[0];
open (MOL2, $mol2_file)
    || die "\nError, cannot open ligand mol2 file: $mol2_file\n";

# assign basename for output files based on input MOL2 filename:

while (<MOL2>)
{
    chomp($_);
    if ($_ =Name)
    {
        $global_count++;
        open (OUT, ">$global_count.mol2")
            || die "\nError, cannot open output mol2 file: $global_count.mol2\n";
        print OUT "$name\n";
        $local_count++;
    }

    if ($_ =~ /^(@<TRIPOS>MOLECULE)/ && $local_count > 1)
    {
        $local_count = 1;
        next;
    }

    if ($_ !~ /^(@<TRIPOS>MOLECULE)/ && $local_count == 1 )
    {
        print OUT "$_\n" ;
        next;
    }
}

print("The number of single Ligand mol2 files generated is $global_count.\n");
close OUT;

问题:这个程序是拆分多分子mol2文件成单一分子的,但是输出文件名不是按原mol2中分子名称输出,而是按1,2,3...顺序输出,要怎样修改程序才能按原mol2中分子名称输出???
您需要登录后才可以回帖 登录 | 我想注册

本版积分规则

QQ|分迪科技|小黑屋|手机版|Archiver|生物分子模拟论坛 ( 蜀ICP备14009200号-3 )

GMT+8, 2024-5-8 08:51 , Processed in 0.080490 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表