#!/bin/env perl =pod =head1 NAME create.yeast.links - create Circos data files with Yeast conservation and duplication links =head1 SYNOPSIS # report conservation links ready for Circos to STDOUT cd conservation cat C* S* Z* | ../create.yeast.links [-coord coords.txt] [-debug] # report duplication links ready for Circos to STDOUT cd duplication cat C* S* Z* | ../create.yeast.links [-coord coords.txt] [-debug] ./create.yeast.links -help ./create.yeast.links -man =head1 DESCRIPTION Create link data files for Circos based on Yeast conservation and duplications. Output is sent to STDOUT, which you should redirect to a file. =head1 OPTIONS =head2 -coord FILE Specify the gene coordinate file, which should be in the format ID CHR START END By default C. =cut use strict; use diagnostics; use warnings FATAL=>"all"; use Data::Dumper; use Getopt::Long; use Pod::Usage; my %CONF = (); my @COMMAND_LINE = ("coord=s", "help", "man", "debug"); GetOptions(\%CONF,@COMMAND_LINE); pod2usage() if $CONF{help}; pod2usage(-verbose=>2) if $CONF{man}; my $id2pos; open(F,$CONF{coord} || "coords.txt"); while() { chomp; my ($id,$chr,$start,$end) = split; $id2pos->{$id} = [$chr,$start,$end]; } close(F); printdebug("read in",int(keys %$id2pos),"gene coordinates"); # Read gene pairs and report chr, start, end for each gene in pair. my $n = 0; while() { chomp; my ($id1,$id2) = split; die "No coordinates for id [$id1]" if ! $id2pos->{$id1}; die "No coordinates for id [$id2]" if ! $id2pos->{$id2}; print join(" ",@{$id2pos->{$id1}}, @{$id2pos->{$id2}})."\n"; $n++; } printdebug("reported $n links"); sub printdebug { printerr(@_) if defined $CONF{debug}; } sub printinfo { print join(" ",map { defined $_ ? $_ : "_undef_" } @_),"\n"; } sub printfinfo { my ($fmt,@args) = @_; @args = map { defined $_ ? $_ : "_undef_" } @args; printf("$fmt\n",@args); } sub printerr { print STDERR join(" ",map { defined $_ ? $_ : "_undef_" } @_),"\n"; } sub printdumper { print Dumper(@_); } sub printdumperq { printdumper(@_); exit; }