Commit a1cdd518 authored by cvs2git's avatar cvs2git
Browse files

This commit was manufactured by cvs2svn to create tag 'freeze-june-15'.

Sprout from branch-freeze-july 2000-10-04 18:22:44 UTC Ewan Birney <birney@sanger.ac.uk> 'backported sticky exons (I hope)'
Delete:
    misc-scripts/golden_path/fpc2staticgp.pl
    misc-scripts/golden_path/mergefpcchr.pl
parent bd85b868
#!/usr/local/bin/perl
=head1 fpc2staticgp
This script turns a modified agp file (with fpc information)
into a tab-delimited file for the static golden path table.
you have to dump out a file of
contig-id,internal_id,start,length
from the mysql database you are loading into. (ie, go
select id,internal_id,offset,length from contig into OUTFILE 'somewhere';
The script is run as
perl fpc2staticgp dump.file *.fpc > static.txt
To make the fpc file, use mergechrfpc.pl
=cut
my $dump = shift;
open(L,">parse.log");
open(D,$dump) || die "Could not open $dump\n";
while(<D>) {
($id,$internal_id,$start,$end) = split;
$id =~ /(\S+)\./ || die "Bad id $id";
$clone = $1;
if( !defined $h{$clone} ) {
$h{$clone} = [];
}
push(@{$h{$clone}},$internal_id);
$start{$internal_id} = $start;
$end{$internal_id} = $start+$end-1;
}
print STDERR "Hash is loaded\n";
foreach my $f ( @ARGV ) {
open(F,$f) || die "could not open $f\n";
while( <F> ) {
# pick up only contig lines. have a +/-
/\-|\+/ || do { next; };
my ($chr,$start,$end,$number,$d,$id,$rstart,$rend,$ori,$fpc,$fstart,$fend) = split;
if( !defined $fend ) {
die "on $_\n";
}
($clone) = $id =~ /(\S+)\./;
#print STDERR "Looking at $clone $id\n";
$seen = 0;
foreach $iid ( @{$h{$clone}} ) {
#print STDERR "Looking at $iid $rstart:$rend ",$start{$iid}," ",$end{$iid},"\n";
if( $rstart >= $start{$iid} && $rstart <= $end{$iid} ) {
if( $rend > $end{$iid} ) {
print L "$f $clone ($id) Bad news... $iid does not fit! $rend vs ",$end{$iid},"\n";
} else {
$seen = 1;
if( $ori eq '-' ) {
$orit = -1;
} else {
$orit = 1;
}
$rstart = $rstart - $start{$iid} +1;
$rend = $rend - $start{$iid} +1;
print "$fpc\t$chr\t$iid\t$start\t$end\t$fstart\t$fend\t$rstart\t$rend\t$orit\tUCSC\n";
last;
}
}
}
if( $seen == 0 ) {
print STDERR "Unable to fit $clone $rstart:$rend\n";
}
}
}
#!/usr/local/bin/perl
=head1 mergefpcchr
This script merges FPC data with chromosomal data agps. It relies heavily
on jim kents directory structure which looks like
For chromosomes
chr-directory/chr_XXX_YYY.agp
For contigs
contig-directory/chr_XXX/ctgZZZ/ctgZZZ.agp
script goes
perl mergefpcchr.pl chr-directory contig-directory
and builds a new chr_XXX_YYY.agp.fpc with the fpc information merged into the
agp information
=cut
my $chr = shift;
my $contigdir = shift;
opendir(CHR,$chr) || die "no chromosome directory";
@chromo = readdir(CHR);
closedir(CHR);
shift(@chromo);
shift(@chromo);
foreach $chromo ( @chromo ) {
$chromo =~ /.*?(\d+).*\.agp/ || next;
$chrnumber = $1;
open(GF,"$chr/$chromo") || die "no $file $!\n";
open(OUT,">$chr/$chromo.fpc");
opendir(DIR,"$contigdir/$chrnumber") || die "no $contigdir/$chrnumber $!\n";
@contigs = readdir(DIR);
closedir(DIR);
shift(@contigs);
shift(@contigs);
foreach $contig ( @contigs ) {
open(F,"$contigdir/$chrnumber/$contig/$contig.agp") || die "did not open $contig $!\n";
while(<F>) {
# chr20 1 1970 1 P AL360078.3 76699 78668 -
/\S+\/(\S+)\s+(\d+)\s+(\d+)\s+\d+\s+\S\s+(\S+)\s+(\d+)\s+(\d+)/ || next;
$id = $1;
$fstart = $2;
$fend = $3;
$accf = $4;
$accst = $5;
$accend = $6;
$idstring = "$accf:$accst:$accend";
#print "Storing $idstring\n";
$fpc{$idstring} = $id;
$fpcstart{$idstring} = $fstart;
$fpcend{$idstring} = $fend;
}
}
while( <GF> ) {
/(\S+)\s+(\d+)\s+(\d+)\s+\d+\s+\S\s+(\S+)\s+(\d+)\s+(\d+)/ || do { print OUT $_; next; };
$id = $1;
$fstart = $2;
$fend = $3;
$accf = $4;
$accst = $5;
$accend = $6;
$idstring = "$accf:$accst:$accend";
if( !defined $fpc{$idstring} ) {
print STDERR "Could not find fpc contig for $idstring\n";
next;
}
chomp;
print OUT "$_ $fpc{$idstring} $fpcstart{$idstring} $fpcend{$idstring}\n";
}
}
Markdown is supported
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