From b4a91b0ce00e9508cacaa77ce9b81d3faa8d7cf5 Mon Sep 17 00:00:00 2001
From: Glenn Proctor <gp1@sanger.ac.uk>
Date: Mon, 27 Jun 2005 12:12:58 +0000
Subject: [PATCH] Simple parser for Agilent probe data.

---
 .../xref_mapping/XrefParser/AgilentParser.pm  | 75 +++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 misc-scripts/xref_mapping/XrefParser/AgilentParser.pm

diff --git a/misc-scripts/xref_mapping/XrefParser/AgilentParser.pm b/misc-scripts/xref_mapping/XrefParser/AgilentParser.pm
new file mode 100644
index 0000000000..6c15006af8
--- /dev/null
+++ b/misc-scripts/xref_mapping/XrefParser/AgilentParser.pm
@@ -0,0 +1,75 @@
+package XrefParser::AgilentParser;
+
+use strict;
+use File::Basename;
+
+use XrefParser::BaseParser;
+
+use vars qw(@ISA);
+@ISA = qw(XrefParser::BaseParser);
+
+# OParser for FASTA-format probe mappings from Agilent
+# >A_23_P253586
+# CTGTCAGGATTCTAGAACTTCTAAAATTAAAGTTTGGGGAAATCAGTAGCTCTGATGAGA
+# >A_23_P217507
+# AGAAAGACGTTTTCCAACATGTAGAACTGCTTTTTAACTGGAGGAAAAATACTTCAGGAG
+
+sub run {
+
+  my ($self, $file, $source_id, $species_id) = @_;
+
+  my @xrefs;
+
+  local $/ = "\n>";
+
+  open(AG,"<".$file) || die "Could not open $file\n";
+
+  while (<AG>) {
+
+    chomp;
+
+    my $xref;
+
+    # strip ^M at end of line
+    $_ =~ s/\015//g;
+    my ($header, $sequence) = $_ =~ /^>?(.+)\n([^>]*)/s or warn("Can't parse FASTA entry: $_\n");
+    my $probe = $header;
+
+    # note header may need to be parsed further in future
+
+    # make sequence into one long string (probably not needed for probes, but just in case)
+    $sequence =~ s/\n//g;
+
+    # build the xref object and store it
+    $xref->{ACCESSION}     = $probe;
+    $xref->{LABEL}         = $probe;
+    $xref->{SEQUENCE}      = $sequence;
+    $xref->{SOURCE_ID}     = $source_id;
+    $xref->{SPECIES_ID}    = $species_id;
+    $xref->{SEQUENCE_TYPE} = 'dna';
+    $xref->{STATUS}        = 'experimental';
+
+    push @xrefs, $xref;
+
+  }
+
+  close(AG);
+
+  print scalar(@xrefs) . " Agilent xrefs succesfully parsed\n";
+
+  XrefParser::BaseParser->upload_xref_object_graphs(\@xrefs);
+
+  print "Done\n";
+
+}
+
+
+sub new {
+
+  my $self = {};
+  bless $self, "XrefParser::AgilentParser";
+  return $self;
+
+}
+
+1;
-- 
GitLab