annotate ragoo.pl @ 8:f98ddf3006f0 draft

Uploaded
author dereeper
date Mon, 26 Jul 2021 17:52:22 +0000
parents 2a9ac8ac9120
children 047933657fae
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;
1
6a1c9991b723 Uploaded
dereeper
parents: 0
diff changeset
4 use File::Basename;
6a1c9991b723 Uploaded
dereeper
parents: 0
diff changeset
5 my $dirname = dirname(__FILE__);
0
90611c479c08 Uploaded
dereeper
parents:
diff changeset
6
90611c479c08 Uploaded
dereeper
parents:
diff changeset
7 my $scaffolds= $ARGV[0];
90611c479c08 Uploaded
dereeper
parents:
diff changeset
8 my $reference = $ARGV[1];
90611c479c08 Uploaded
dereeper
parents:
diff changeset
9 my $output = $ARGV[2];
90611c479c08 Uploaded
dereeper
parents:
diff changeset
10 my $output2 = $ARGV[3];
90611c479c08 Uploaded
dereeper
parents:
diff changeset
11
90611c479c08 Uploaded
dereeper
parents:
diff changeset
12 my $tmpdir = "tmpdir$$";
90611c479c08 Uploaded
dereeper
parents:
diff changeset
13
90611c479c08 Uploaded
dereeper
parents:
diff changeset
14 mkdir($tmpdir);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
15
90611c479c08 Uploaded
dereeper
parents:
diff changeset
16
90611c479c08 Uploaded
dereeper
parents:
diff changeset
17 my ($sc) = split(",",$scaffolds);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
18 $scaffolds = $sc;
90611c479c08 Uploaded
dereeper
parents:
diff changeset
19
90611c479c08 Uploaded
dereeper
parents:
diff changeset
20 system("cp -rf $scaffolds $tmpdir/scaffolds.fa");
90611c479c08 Uploaded
dereeper
parents:
diff changeset
21 system("cp -rf $reference $tmpdir/reference.fa");
90611c479c08 Uploaded
dereeper
parents:
diff changeset
22 chdir($tmpdir);
4
2a9ac8ac9120 Uploaded
dereeper
parents: 3
diff changeset
23 system("$dirname/ragoo.py scaffolds.fa reference.fa >>$output 2<&1");
0
90611c479c08 Uploaded
dereeper
parents:
diff changeset
24
90611c479c08 Uploaded
dereeper
parents:
diff changeset
25
90611c479c08 Uploaded
dereeper
parents:
diff changeset
26 my %hash;
90611c479c08 Uploaded
dereeper
parents:
diff changeset
27 my $id;
90611c479c08 Uploaded
dereeper
parents:
diff changeset
28 open(F,"ragoo_output/ragoo.fasta");
90611c479c08 Uploaded
dereeper
parents:
diff changeset
29 while(<F>){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
30 if (/>(.*)/){$id = $1;}
90611c479c08 Uploaded
dereeper
parents:
diff changeset
31 else{
90611c479c08 Uploaded
dereeper
parents:
diff changeset
32 $hash{$id}.= $_;
90611c479c08 Uploaded
dereeper
parents:
diff changeset
33 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
34 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
35 close(F);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
36
3
2390a7ae4853 Uploaded
dereeper
parents: 1
diff changeset
37 open(O,">>$output");
0
90611c479c08 Uploaded
dereeper
parents:
diff changeset
38 foreach my $id(keys(%hash)){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
39 print O ">$id\n";
90611c479c08 Uploaded
dereeper
parents:
diff changeset
40 my $seq = $hash{$id};
90611c479c08 Uploaded
dereeper
parents:
diff changeset
41 for (my $i =0; $i <= length($seq); $i =$i+80){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
42 my $subseq = substr($seq,$i,80);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
43 print O "$subseq\n";
90611c479c08 Uploaded
dereeper
parents:
diff changeset
44 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
45 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
46 close(O);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
47
90611c479c08 Uploaded
dereeper
parents:
diff changeset
48 open(O,">$output2");
90611c479c08 Uploaded
dereeper
parents:
diff changeset
49 foreach my $id(keys(%hash)){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
50 if ($id =~/Chr0_RaGOO/){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
51 next;
90611c479c08 Uploaded
dereeper
parents:
diff changeset
52 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
53 print O ">$id\n";
90611c479c08 Uploaded
dereeper
parents:
diff changeset
54 my $seq = $hash{$id};
90611c479c08 Uploaded
dereeper
parents:
diff changeset
55 for (my $i =0; $i <= length($seq); $i =$i+80){
90611c479c08 Uploaded
dereeper
parents:
diff changeset
56 my $subseq = substr($seq,$i,80);
90611c479c08 Uploaded
dereeper
parents:
diff changeset
57 print O "$subseq\n";
90611c479c08 Uploaded
dereeper
parents:
diff changeset
58 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
59 }
90611c479c08 Uploaded
dereeper
parents:
diff changeset
60 close(O);