[Bio] / FigKernelScripts / assign_synonym_ids_to_nr.pl Repository:
ViewVC logotype

View of /FigKernelScripts/assign_synonym_ids_to_nr.pl

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.1 - (download) (as text) (annotate)
Tue Sep 27 16:02:54 2005 UTC (14 years, 4 months ago) by olson
Branch: MAIN
CVS Tags: caBIG-dataload-0, caBIG-00-00-00
Scripts for assigning xxx numbers to peg.syn and friends.

# Scan an NR, replacing the existing IDs with the corresponding principal
# synonym id's from the given ID map file.

use strict;

my $usage = "assign_synonym_ids_to_nr NR id.map NewNR";

@ARGV == 3 or die $usage;

my $old_nr = shift;
my $id_map = shift;
my $new_nr = shift;

open(ONR, "<$old_nr") or die "Cannot open $old_nr for reading: $!\n";
open(MAP, "<$id_map") or die "Cannot open $id_map for reading: $!\n";
open(NNR, ">$new_nr") or die "Cannot open $new_nr for writing: $!\n";

my %map;

while (<MAP>)
    my($k,$v) = split(/\t/);
    $map{$k} = $v;


print "Read map\n";

local $/ = "\n>";

my($id, $rest, $seq);
while (<ONR>)
    if (($id, $rest, $seq) = /^>?(\S+)([^\n]*)\n(.*)/s)
	my $new = $map{$id};

	if (!defined($new))
	    warn "No mapped id found for $id\n";
	    $new = $id;
	print NNR ">$new$rest\n$seq\n";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3