view ragoo.pl @ 9:35f0fcf77bdf draft

Deleted selected files
author dereeper
date Mon, 26 Jul 2021 18:00:34 +0000
parents 2a9ac8ac9120
children 047933657fae
line wrap: on
line source

#!/usr/bin/perl

use strict;
use File::Basename;
my $dirname = dirname(__FILE__);

my $scaffolds= $ARGV[0];
my $reference = $ARGV[1];
my $output = $ARGV[2];
my $output2 = $ARGV[3];

my $tmpdir = "tmpdir$$";

mkdir($tmpdir);


my ($sc) = split(",",$scaffolds);
$scaffolds = $sc;

system("cp -rf $scaffolds $tmpdir/scaffolds.fa");
system("cp -rf $reference $tmpdir/reference.fa");
chdir($tmpdir);
system("$dirname/ragoo.py scaffolds.fa reference.fa >>$output 2<&1");


my %hash;
my $id;
open(F,"ragoo_output/ragoo.fasta");
while(<F>){
	if (/>(.*)/){$id = $1;}
	else{
		$hash{$id}.= $_;
	}
}
close(F);

open(O,">>$output");
foreach my $id(keys(%hash)){
	print O ">$id\n";
	my $seq = $hash{$id};
	for (my $i =0; $i <= length($seq); $i =$i+80){
		my $subseq = substr($seq,$i,80);
		print O "$subseq\n";
	}
}
close(O);

open(O,">$output2");
foreach my $id(keys(%hash)){
        if ($id =~/Chr0_RaGOO/){
                next;
        }
        print O ">$id\n";
        my $seq = $hash{$id};
        for (my $i =0; $i <= length($seq); $i =$i+80){
                my $subseq = substr($seq,$i,80);
                print O "$subseq\n";
        }
}
close(O);