Skip to content
Snippets Groups Projects
Commit c46eb26d authored by Graham McVicker's avatar Graham McVicker
Browse files

crufty

parent a7879552
No related branches found
No related tags found
No related merge requests found
#!/usr/local/bin/perl
use strict;
=head1 NAME
=head1 SYNOPSIS
=head1 DESCRIPTION
=cut
use Bio::EnsEMBL::Analysis::PairAlign;
use Bio::EnsEMBL::SeqFeature;
use Bio::EnsEMBL::FeaturePair;
use Bio::SeqFeature::FeaturePair;
use Getopt::Long;
# Takes an msp file and a series of coords to convert as input
my $file = shift;
my @coords = @ARGV;
open(IN,"<$file") || die "Can't open file $file";
my $infh = \*IN;
my %pairs;
while (my $line = <$infh>) {
my $pair = read_FeaturePair($line);
my $id = $pair->primary_tag;
if (!defined($pairs{$id})) {
$pairs{$id} = new Bio::EnsEMBL::Analysis::PairAlign;
}
$pairs{$id}->addFeaturePair($pair);
}
foreach my $key (keys %pairs) {
foreach my $pair1 ($pairs{$key}->eachFeaturePair) {
my $pair2 = $pair1->feature2;
;
print($pair1->start . " " .
$pair1->end . " " .
$pair2->start . " " .
$pair2->end . "\n");
}
foreach my $c (@coords) {
my $out = $pairs{$key}->genomic2cDNA($c);
print("Genomic $c - cDNA $out\n");
}
}
sub read_FeaturePair {
my ($line) = @_;
chomp($line);
my ($score,$pid,$qstart,$qend,$id1,$hstart,$hend,$id2,$desc) = split(' ',$line,9);
my $strand1 = 1;
my $strand2 = 1;
if ($qstart > $qend ) {
my $tmp = $qend;
$qend = $qstart;
$qstart = $tmp;
$strand1 = -1;}
if ($hstart > $hend ) {
my $tmp = $hend;
$hend = $hstart;
$hstart = $tmp;
$strand2 = -1;
}
my $sf1 = new Bio::EnsEMBL::SeqFeature(-start => $qstart,
-end => $qend,
-strand => $strand1,
-primary_tag => $id1);
my $sf2 = new Bio::EnsEMBL::SeqFeature(-start => $hstart,
-end => $hend,
-strand => $strand2,
-primary_tag => $id2);
my $fp = new Bio::EnsEMBL::FeaturePair(-feature1 => $sf1,
-feature2 => $sf2,
);
return ($fp);
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment