自动IP禁止访问

由于最近服务器经常受到黑客攻击,于是写了此程序,用于禁用某些ip访问

#!/usr/bin/perl -w
use strict;
use warnings;
use File::Copy;
use Getopt::Long;

my $usage=<<USAGE;
Usage:
    perl $0 -i_a <input_dir_a(httpd.conf)> -f_a <file_name_a(httpd.conf)> -i_b <input_dir_b(httpd.log)> -f_b <file_name_b(httpd.log)>
USAGE
if (@ARGV==0){die $usage}

my ($input_dir_a,$input_filename_a,$input_dir_b,$input_filename_b,$help);
GetOptions(
    "i_a:s" => \$input_dir_a,
    "f_a:s" => \$input_filename_a,
    "i_b:s" => \$input_dir_b,
    "f_b:s" => \$input_filename_b,
    "h:s" => \$help
);

die `pod2text $0` if ((!$input_dir_a) or (!$input_dir_b));

=head1 Description

    This script is used to auto forbid ip which heat your website with LAMP architecture;

=head1 Parameters

    -i_a  [str]   input dir to httpd.conf file
    -f_a    [str]       input file name (such as httpd.conf)
    -i_b    [str]       input dir to httpd log dir
    -f_b    [str]       input file name (such as access_log)
    -h  [str]   Help manual

=cut

#print $input_dir_a,"\n";
my $config_file = "$input_dir_a"."/"."$input_filename_a";
my $log_file = "$input_dir_b"."/"."$input_filename_b";
#print $log_file;

copy($config_file,$config_file.".bak");

my %hash;
my @appear_time;

open(RF,$log_file) || die $!;
while(my $line=<RF>){
    chomp($line);
    my @arr=split(' ',$line);
    if($arr[0]!~/^\d/){next};
    if($arr[0] eq "127.0.0.1"){next};
    $hash{$arr[0]}++;
}
close(RF);


open(RF,$config_file) || die $!;
open(WF,">".$config_file."_a") || die $!;
while(my $line=<RF>){
    chomp($line);
    if($line =~ /Deny\ from\ (.*)/){
        my $ip_temp = $1;
        for my $key (keys %hash){
            if ($key ne $ip_temp){
                if($hash{$key} > 7000){
                    my $new_line=$line."\n"."    "."Deny from ".$key."\n";
                    print WF $new_line;
                    delete($hash{$key});
                }
            }else{
                delete($hash{$key});
            }
        }
        next;
    }
    print WF $line."\n";
}
close(RF);
close(WF);

move($config_file."_a",$config_file);
发表在 Linux, Perl | 留下评论

HiC数据差异loops分析

使用Juicer的hiccupsdiff分析,这里调用GPU加速计算

source ~/.bashrc.cuda-8.0
cd /home/train/data/hic_data/project/hic-pro_old
mkdir hiccupdiff
cd hiccupdiff/
ln -sv ~/data/hic_data/project/hic-pro_old/hiccups/outdir/PRAD.hic 22Rv1a.hic
ln -sv ~/data/hic_data/project/hic-pro_old/hiccups-RWPE1/outdir/PRAD.hic RWPE1d.hic
ln -sv ~/data/hic_data/project/hic-pro_old/hiccups-RWPE1/hiccups_results/merged_loops.bedpe RWPE1d_merged_loops.bedpe
ln -sv ~/data/hic_data/project/hic-pro_old/hiccups/hiccups_results/merged_loops.bedpe 22Rv1a_merged_loogs.bedpe
java -jar /opt/biosoft/juicer/scripts/common/juicer_tools.jar hiccupsdiff -m 2048 -k KR RWPE1d.hic 22Rv1a.hic RWPE1d_merged_loops.bedpe 22Rv1a_merged_loogs.bedpe diff_loop
发表在 3D_genome | 一条评论

Vina 的虚拟筛选

git clone https://github.com/daizao/Do_virtual_screening
# 根据需要修改自己文件
perl run.pl
发表在 Perl, Quantum Chemical Calculation | 留下评论

Git 入门命令

#local
git init
git status
git add file/doc
git commit -m "..."
git commit -a -m "..."
git status
git log


git show ... #一串哈希符号

#remote
git remote -v
git remote add origin https:.......
git remote -v
git push origin master #输入用户名和密码,将本地文件push到远程


git pull origin master #将远程的文件拽到本地



git clone https:...... #将远程的文件拽到本地
git remote -v #clone的仓库直接和远程仓库建立了联系
git commit -a -m "add daizao char" #将修改记录信息
git push
发表在 Linux | 留下评论

Autodock vina 源码编译安装

sudo yum install imake #install makedepend
sudo yum install libicu-devel #install unicode/icu for boostregex
sudo yum install openmpi openmpi-devel  #install opemnpi
sudo yum install glibc-static

tar -zxf boost_1_41_0.tar.gz
cd boost_1_41_0
./bootstrap.sh --prefix=/opt/sysoft/boost-1.41.0
./bjam install
cd ..
rm -rf boost_1_41_0

tar -zxf autodock_vina_1_1_2.tgz
cd /home/train/autodock_vina_1_1_2/build/linux/release
vim Makefile
#chang the path of g++ and base path
#BASE=/opt/sysoft/boost-1.41.0
#GPP=/usr/bin/g++
export LIBRARY_PATH=/opt/sysoft/boost-1.41.0/lib:$LIBRARY_PATH
export CPLUS_INCLUDE_PATH=/opt/sysoft/boost-1.41.0/include:$CPLUS_INCLUDE_PATH
#make depend
make
mv autodock_vina_1_1_2 /opt/biosoft/
mkdir /opt/biosoft/autodock_vina_1_1_2/bin
cp /opt/biosoft/autodock_vina_1_1_2/build/linux/release/vina* /opt/biosoft/autodock_vina_1_1_2/bin/
发表在 Linux, Molecular Dynamics | 留下评论

PyClone 源码安装

#由于0.13.1版本numba依赖关系作者描述不清不建议使用
#PyClone 0.13.0 install
git clone -b 0.2.3 https://github.com/Roth-Lab/pydp.git
cd pydp/
pip install . --prefix=/opt/sysoft/pydp-0.2.3
echo 'export PYTHONPATH=/opt/sysoft/pydp-0.2.3/lib/python2.7/site-packages:$PYTHONPATH' >> ~/.bashrc.pydp-0.2.3
cd ..
rm -rf pydp/

pip install 'matplotlib>=1.2.0'
pip install 'numpy>=1.6.2'
pip install 'pandas>=0.11'
pip install 'scipy>=0.11'
pip install 'seaborn>=0.6.0'

wget -c https://bitbucket.org/aroth85/pyclone/downloads/PyClone-0.13.0.tar.gz
tar -zxf PyClone-0.13.0.tar.gz
cd PyClone-0.13.0/
pip install . --prefix=/opt/biosoft/pyclone-0.13.0
echo 'export PATH=/opt/biosoft/pyclone-0.13.0/bin:$PATH' >> ~/.bashrc.pyclone-0.13.0
echo 'export PYTHONPATH=/opt/biosoft/pyclone-0.13.0/lib/python2.7/site-packages:$PYTHONPATH' >> ~/.bashrc.pyclone-0.13.0
echo 'source ~/.bashrc.pydp-0.2.3' >> ~/.bashrc.pyclone-0.13.0
发表在 NGS_analysis | 留下评论