Wednesday, 18 June 2014

DiffReps

Perl Packages contained in the diffReps Collection

Perl Library: MyShortRead

MyShortRead::SRBed object:
sub new{
    my $class = shift;
    my $self = {};
    $self->{file_name} = undef;
    $self->{bin_size} = 1000;
    $self->{window_size} = 1000;
    $self->{frag_size} = 100;
    $self->{chr_list} = {};    # hash table: chrom -> ChromBed
    bless($self, $class);
    # User supplied bed file name.
    if(@_ >= 1) {$self->{file_name} = $_[0];}
    if(@_ >= 2) {$self->{bin_size} = $_[1];}
    if(@_ >= 3){$self->{frag_size} = $_[2];}
    return $self;
}

MyShortRead::ChromBed object:
sub new{
    my $class = shift;
    my $self = {};
    $self->{chrom_name} = undef;
    $self->{chrom_len} = undef;
    $self->{file_name} = undef;    # chromosome file name.
    $self->{bin_num} = undef;    # number of bins for the chromosome.
    $self->{bin_count} = [];    # vector for bin read count.
    $self->{bin_count_F} = [];    # bin Forward strand read count.
    $self->{bin_count_R} = [];    # bin Reverse strand read count.
    $self->{window_num} = undef;    # number of sliding windows.
    $self->{window_count} = [];    # vector for window read count.
    $self->{window_count_F} = [];    # window read count for Forward strand.
    $self->{window_count_R} = [];    # window read count for Reverse strand.
    bless($self, $class);
    # User supplied chromosome name, length and file name.
    if(@_ >= 3){
        $self->{chrom_name} = $_[0];
        $self->{chrom_len} = $_[1];
        $self->{file_name} = $_[2];
    }
    return $self;
}
my $signRegion = new diffReps::ChromaModSite;


diffReps::SlideWindow object:
sub new{
    my $class = shift;
    my $self = {
        chrom => undef,
        winN => undef,        # window number to retrieve count from SRBed class.
        maxN => undef,        # maximum window number.   
        retrieved => 0,        # boolean tag: whether count data have been retrieved?
        rep_cnt => [],        # normalized replicate counts.
        rep_cnt_ => [],        # normalized treatment counts using #reads.
        brep_cnt => [],        # normalized background treatment counts.
        rsumRep => undef,    # sum of raw replicate counts.
        dirn => undef,        # change direction: 'Up' or 'Down'.
        logFC => undef,        # log2 fold change.
        pval => undef        # P-value.
    };
    bless $self, $class;
    return $self;
}
my $slideWindow = new diffReps::SlideWindow;


diffReps::RegionList object:
sub new{
    my $class = shift;
    my $self = {
        regList => [],    # region list.
        adjusted => 0    # bool tag for P-value adjustment.
    };
    bless $self, $class;
    return $self;
}
my $regList = new diffReps::RegionList;


WindowCoverage object defined in diffReps.pl:
 sub new{
    die "Not enough arguments to set up window coverage class! Stop.\n" if @_ < 3;
    my($class,$winSize,$step) = @_;
    my $self = {
        movingCov => 0,
        windowCov => 0,
        winSize => $winSize,
        step => $step
    };
    bless $self, $class;
    return $self;
}


diffReps::ChromaModSite object:
sub new{
    my $class = shift;
    my $self = {
        chrom => undef,
        start => undef,
        end => undef,
        siteCenter => undef,
        retrieved => 0,        # boolean tag: whether count data have been retrieved?
        rep_cnt => [],        # region normalized replicate counts.
        rep_cnt_ => [],        # normalized replicate counts using #reads.
        brep_cnt => [],        # normalized background replicate counts.
        #repEnr => undef,        # replicate enrichment vs. background.
        rsumRep => undef,    # sum of raw replicate counts.
        dirn => undef,        # change direction: 'Up' or 'Down'.
        logFC => undef,        # log2 fold change.
        winSta => undef,    # best window start.
        #winRep => [],        # window normalized replicate counts.
        winFC => undef,        # window log2 fold change.
        winP => undef,        # window P-value.
        winQ => undef        # window adjusted P-value.
    };
    bless $self, $class;
    return $self;
}

No comments:

Post a Comment