Get Motif file in the result of HOMER (根据HOMER结果获取motif文件)

#!/usr/bin/perl -w
use strict;
use warnings;

my $usage=<<USAGE;
Usage:
    perl get_motif_file.pl gene_name /path/to/all.motif_file /path/to/motifFile
USAGE
if(@ARGV==0){die $usage};


my $file1=$ARGV[0];
my $file2=$ARGV[1];
my $file3=$ARGV[2];
my @data;

open(RF,$file2) || die $!;
open(WF,">process.txt") || die $!;
while(my $line=<RF>){
    chomp($line);
    push @data, $line;
    my $temp="\t";
    push @data, $temp;
}
print WF @data;
close(RF);
close(WF);

open(RF,"process.txt") || die $!;
open(WF,">process_1.txt") || die $!;
while (my $line=<RF>){
    my @arr=split(/>/,$line);
    for my $i (1..$#arr){
        print WF ">".$arr[$i]."\n";
    }
}
close(RF);
close(WF);

my $g=0;
open(RF,"process_1.txt") || die $!;
open(WF,">".$file3) || die $!;
while(my $line=<RF>){
    chomp($line);
    my @arr=split(/\t/,$line);
    my @gene=split(/\(/,$arr[1]);
    if ($gene[0] eq $file1){
        for my $i (0..4){
            print WF $arr[$i]."\t";
        }
        print WF $arr[5]."\n";
        for my $j (6..$#arr){
            if ($g <= 2){
                print WF $arr[$j]."\t";
            }
            if ($g==3){
                print WF $arr[$j]."\n";
                $g=0;
                next;
            }
            $g=$g+1;
        }
        }
    }
close(RF);
close(WF);
此条目发表在NGS_analysis, Perl分类目录。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Protected with IP Blacklist CloudIP Blacklist Cloud