-
Notifications
You must be signed in to change notification settings - Fork 0
/
Splitter.pl
46 lines (31 loc) · 982 Bytes
/
Splitter.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl -w
use strict;
use warnings;
#IMPORTANT: Must have a blank line between chromosomes.
#This part just searches for new lines
#Help section
local $/ = ''; #I have no idea what this does dude
#Just says what file you're opening
my $in = $ARGV[0];
my $strain = $ARGV[1];
print "Splitting up the file $in\n";
my $Chr = "_Chr";
my $label = "$strain$Chr";
my $count = "A";
my $count2 = 1;
#Opens file and creates new files?
while (<>) {
my $nfname = "$label$count";
my ($fileName) = $nfname;
# my ($fileName) = /^>([^\s]+)/; #old label, we can add out own, yay :D
open my $fh, '>', "$fileName.txt" or die "Can't write to '$fileName.txt'";
chomp $_; #removes trailing new line, can cause issues in calculation
print $fh $_;
close $fh;
#Last bit just says to stop at end chromosome, which for us is M
if ($count eq "M"){
last;}
$count++;
$count2++
}
print "Done, generated $count2 files.\n"