~/bin/hapinfoMergeByChrosome.pl
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";