-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchop-reads-files-user.pl
52 lines (52 loc) · 1.06 KB
/
chop-reads-files-user.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
47
48
49
50
51
52
#!/usr/bin/perl
#chop sequences in one file into different file based on the number of sequences per reads by user.
$infile=$ARGV[0];
print "How many sequence you have?";
$sequenceNumber=<STDIN>;
#chomp($sequenceNumber);
print "How many sequence per file?";
$sequencesPerFile=<STDIN>;
#chomp($sequencesPerFile);
my $cntr=0;
my $filecntr=0;
$fileNumber=int($sequenceNumber/$sequencesPerFile);
#for (my $i=0; $i<$fileNumber;$i++)
#{
# my $newOutput="output$i";
# open ($newOutput, ">$infile.$i");
# print $newOutput;$pauze=<STDIN>;
#}
#$outputFile=$output."0";
open(output0,">$infile.0");
$outputfile="output0";
open (inputF, $infile) || die print "there is no file";
while(<inputF>)
{
$line=$_;
if (/^>/)
{
$cntr++;
if ($cntr < $sequencesPerFile + 1)
{
print $outputfile $line;
}
else
{
$filecntr++;
$outputfile="output$filecntr";
open($outputfile, ">$infile.$filecntr");
print $outputfile $line;
$cntr="";
}
}
else
{
print $outputfile $line;
}
}
close inputF;
for (my $j=0; $j<$fileNumber;$j++)
{
$closeFile="output$j";
close $closeFile;
}