annotate ragoo.pl @ 0:90611c479c08 draft

Uploaded
author dereeper
date Mon, 21 Jun 2021 21:10:57 +0000
parents
children 6a1c9991b723
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
90611c479c08 Uploaded
dereeper
parents:
diff changeset
1 #!/usr/bin/perl
90611c479c08 Uploaded
dereeper
parents:
diff changeset
2
90611c479c08 Uploaded
dereeper
parents:
diff changeset
3 use strict;
90611c479c08 Uploaded
dereeper
parents:
diff changeset
4
90611c479c08 Uploaded
dereeper
parents:
diff changeset
5 my $scaffolds= $ARGV[0];
90611c479c08 Uploaded
dereeper
parents:
diff changeset
6 my $reference = $ARGV[1];
90611c479c08 Uploaded
dereeper
parents:
diff changeset
7 my $output = $ARGV[2];
90611c479c08 Uploaded
dereeper
parents:
diff changeset
8 my $output2 = $ARGV[3];
90611c479c08 Uploaded
dereeper
parents:
diff changeset
9
90611c479c08 Uploaded
dereeper
parents:
diff changeset
10 my $tmpdir = "tmpdir$$";
90611c479c08 Uploaded
dereeper
parents:
diff changeset
11
90611c479c08 Uploaded
dereeper
parents:
diff changeset
12 mkdir($tmpdir);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
13
90611c479c08 Uploaded
dereeper
parents:
diff changeset
14
90611c479c08 Uploaded
dereeper
parents:
diff changeset
15 my ($sc) = split(",",$scaffolds);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
16 $scaffolds = $sc;
90611c479c08 Uploaded
dereeper
parents:
diff changeset
17
90611c479c08 Uploaded
dereeper
parents:
diff changeset
18 system("cp -rf $scaffolds $tmpdir/scaffolds.fa");
90611c479c08 Uploaded
dereeper
parents:
diff changeset
19 system("cp -rf $reference $tmpdir/reference.fa");
90611c479c08 Uploaded
dereeper
parents:
diff changeset
20 chdir($tmpdir);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
21 system("ragoo.py scaffolds.fa reference.fa");
90611c479c08 Uploaded
dereeper
parents:
diff changeset
22
90611c479c08 Uploaded
dereeper
parents:
diff changeset
23
90611c479c08 Uploaded
dereeper
parents:
diff changeset
24 my %hash;
90611c479c08 Uploaded
dereeper
parents:
diff changeset
25 my $id;
90611c479c08 Uploaded
dereeper
parents:
diff changeset
26 open(F,"ragoo_output/ragoo.fasta");
90611c479c08 Uploaded
dereeper
parents:
diff changeset
27 while(<F>){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
28 if (/>(.*)/){$id = $1;}
90611c479c08 Uploaded
dereeper
parents:
diff changeset
29 else{
90611c479c08 Uploaded
dereeper
parents:
diff changeset
30 $hash{$id}.= $_;
90611c479c08 Uploaded
dereeper
parents:
diff changeset
31 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
32 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
33 close(F);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
34
90611c479c08 Uploaded
dereeper
parents:
diff changeset
35 open(O,">$output");
90611c479c08 Uploaded
dereeper
parents:
diff changeset
36 foreach my $id(keys(%hash)){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
37 print O ">$id\n";
90611c479c08 Uploaded
dereeper
parents:
diff changeset
38 my $seq = $hash{$id};
90611c479c08 Uploaded
dereeper
parents:
diff changeset
39 for (my $i =0; $i <= length($seq); $i =$i+80){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
40 my $subseq = substr($seq,$i,80);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
41 print O "$subseq\n";
90611c479c08 Uploaded
dereeper
parents:
diff changeset
42 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
43 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
44 close(O);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
45
90611c479c08 Uploaded
dereeper
parents:
diff changeset
46 open(O,">$output2");
90611c479c08 Uploaded
dereeper
parents:
diff changeset
47 foreach my $id(keys(%hash)){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
48 if ($id =~/Chr0_RaGOO/){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
49 next;
90611c479c08 Uploaded
dereeper
parents:
diff changeset
50 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
51 print O ">$id\n";
90611c479c08 Uploaded
dereeper
parents:
diff changeset
52 my $seq = $hash{$id};
90611c479c08 Uploaded
dereeper
parents:
diff changeset
53 for (my $i =0; $i <= length($seq); $i =$i+80){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
54 my $subseq = substr($seq,$i,80);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
55 print O "$subseq\n";
90611c479c08 Uploaded
dereeper
parents:
diff changeset
56 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
57 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
58 close(O);