~/bin/hapinfoMergeByChrosome.pl

From ZhangLabWiki
Revision as of 23:37, 5 March 2016 by >Shicheng (Created page with " #!/usr/bin/perl -w # Hapinfo to methylation haplotype load (MHL) # Run the script to the Hapinfo directory # Contact: Shicheng Guo # Version 1.3 # Update: 2016-02-29 us...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#!/usr/bin/perl -w
# Hapinfo to methylation haplotype load (MHL)
# Run the script to the Hapinfo directory
# Contact: Shicheng Guo
# Version 1.3
# Update: 2016-02-29
use strict;
use Cwd;
my $usage = <<USAGE;
perl $0 Directory_of_haploinfo
USAGE
my %sam;
system("rm -rf ../mergeHapinfo") if ( -e "../mergeHapinfo");
print "remove ../mergeHapinfo succeed.\n";
mkdir "../mergeHapinfo" if (! -e "../mergeHapinfo");
print "creat ../mergeHapinfo succeed.\n";
my @hapInfo_files= glob("*.hapInfo.txt");
foreach my $file(@hapInfo_files){
my ($sam,undef)=split /\./,$file;
$sam{$sam}=$sam;
}
foreach my $sam(sort keys %sam){
my @file=glob("$sam*.hapInfo.txt");
foreach my $file(@file){
print "$sam\t$file\n";
system("cat $file >> ../mergeHapinfo/$sam.hapInfo.txt");
}
print "merge $sam Hapinfo files succeed.\n";
}
print "merge Hapinfo files succeed.\n";