limit fstBC to 30bp in Python3 ver.
[GalaxyCodeBases.git] / projects / recombineMap / sperm_by_fw / snp_calling / make_SE_pirs_matrix.pl
blobe764d44fa0141b47a07ae956b1bc90a5bf16a5aa
1 #!/usr/bin/perl
3 =head1 Name
5 snp_dist_filter.pl -- filter snp by neigboring distance
7 =head1 Description
11 =head1 Version
13 Author: Fan Wei, fanw@genomics.org.cn
14 Version: 1.0, Date: 2006-12-6
15 Note:
17 =head1 Usage
18 snp_dist_filter.pl <*.cns.snp>
19 --distance <int> set the minimum distance between two neighboring SNPs, default=5
20 --verbose output running progress information to screen
21 --help output help information to screen
23 =head1 Exmple
27 =cut
29 use strict;
30 use Getopt::Long;
31 use FindBin qw($Bin $Script);
32 use File::Basename qw(basename dirname);
33 use Data::Dumper;
34 use File::Path; ## function " mkpath" and "rmtree" deal with directory
36 ##get options from command line into variables and set default values
37 my ($Dist_cutoff, $Verbose,$Help);
38 GetOptions(
39 "distance:i"=>\$Dist_cutoff,
40 "verbose"=>\$Verbose,
41 "help"=>\$Help
43 $Dist_cutoff ||= 5;
44 die `pod2text $0` if (@ARGV == 0 || $Help);
46 my $head;
47 my %data;
49 while (<>) {
50 if (/^\#/) {
51 $head .= $_;
54 if (/^\w/) {
55 my @t = split /\s+/;
56 my $ref = shift @t;
57 my $cycle = shift @t;
58 $data{$ref}{$cycle} = \@t;
60 if(/^</){
61 last;
65 $head =~ s/Cycle_number 200/Cycle_number 100/;
67 print $head;
69 #print Dumper \%data;
71 my $outstr;
72 foreach my $ref (sort keys %data) {
73 my $ref_p = $data{$ref};
74 for (my $i=1; $i<=100; $i++) {
75 $outstr .= "$ref\t$i";
76 my $read1_p = $ref_p->{$i};
77 my $read2_p = $ref_p->{$i+100};
78 for (my $j=0; $j<@$read1_p; $j++) {
79 my $sum = $read1_p->[$j] + $read2_p->[$j];
80 $outstr .= "\t$sum";
82 $outstr .= "\n";
86 print $outstr;