None available.
sub create_xrefs
{
my ($self, $source_id, $species_id, $file, $verbose) = @_;
my ($count, $noseq, $direct) = (0,0,0);
$| = 1;
my @xrefs;
my $file_io = $self->get_filehandle($file);
if ( !defined $file_io ) {
print STDERR "ERROR: Could not open $file\n";
return 1; }
$file_io->getline();
while ( $_ = $file_io->getline() ) {
my $xref;
my @fields = split /\t/;
my $acc = $fields[0];
chomp($acc);
$acc =~ s/\"//g;
my $target = $fields[2];
chomp($target);
$target =~ s/\"//g;
if ($target =~ /ENSGALT/) {
($target) = $target =~ /([^.]*)\.([^.]*)/;
my $xref_id = $self->add_xref($acc, 0, $acc, "$target direct mapping", $source_id, $species_id);
$self->add_direct_xref($xref_id, $target, "transcript", "");
$direct++;
} else {
system ("pfetch -q $target > seq.txt");
my $seq_io = $self->get_filehandle('seq.txt');
my $seq = $seq_io->getline();
$seq_io->close();
chomp($seq);
if ($seq && $seq !~ /no match/) {
$xref->{ACCESSION} = $acc;
$xref->{SEQUENCE} = $seq;
$xref->{LABEL} = $acc;
$xref->{SOURCE_ID} = $source_id;
$xref->{SPECIES_ID} = $species_id;
$xref->{SEQUENCE_TYPE} = 'dna';
$xref->{STATUS} = 'experimental';
$xref->{DESCRIPTION} = $target . " used as mapping target";
$count++;
print "$count " if (($count % 100 == 0) and $verbose);
push @xrefs, $xref;
} else {
print STDERR "Couldn't get sequence for $target\n";
$noseq++;
}
}
}
$file_io->close();
if($verbose){
print "\n\nParsed $count primary xrefs.\n";
print "Couldn't get sequence for $noseq primary_xrefs\n" if ($noseq);
print "Added $direct direct xrefs.\n";
}
return\@ xrefs;
}
1; } |
sub run
{
my $self = shift if (defined(caller(1)));
my $source_id = shift;
my $species_id = shift;
my $files = shift;
my $release_file = shift;
my $verbose = shift;
my @xrefs = $self->create_xrefs($source_id, $species_id, @{$files}[0], $verbose);
if(!@xrefs){
return 1; }
if(!defined(XrefParser::BaseParser->upload_xref_object_graphs(@xrefs))){
return 1;
}
return 0; } |