Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bug 2074/2329

svn path=/bioperl-ext/trunk/; revision=680
  • Loading branch information...
commit 79d9b360da3af691bc5608061d764df188bbe7a9 1 parent ddd6cee
cjfields authored
Showing with 109 additions and 29 deletions.
  1. +22 −28 Bio/SeqIO/staden/read.pm
  2. +87 −1 Bio/SeqIO/staden/read.xs
50 Bio/SeqIO/staden/read.pm
View
@@ -61,39 +61,11 @@ DynaLoader::bootstrap Bio::SeqIO::staden::read $Bio::SeqIO::staden::read::VERSIO
@Bio::SeqIO::staden::read::EXPORT_OK = ();
sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaking
-# --------- start mackey code ---------
-# - # package Bio::SeqIO::staden::read;
-
-# - # use strict;
-# - # use vars qw(@ISA $VERSION $HAS_INLINE);
use Bio::Root::Root;
use vars qw(@ISA);
my @ISA = ( 'Bio::Root::Root', @ISA );
-# - # sub BEGIN {
-# - # eval {
-# - # require Inline;
-# - #
-# - # # Debugging tools:
-# - # # use Inline C => (Config =>
-# - # # CC => '/opt/parasoft/bin.linux2/insure',
-# - # # OPTIMIZE => '-g',
-# - # # );
-# - #
-# - # use Inline (C => 'DATA',
-# - # VERSION => '1.51',
-# - # NAME => 'Bio::SeqIO::staden::read',
-# - # LIBS => "-L/usr/local/lib -lread -lz", # leave these as double quotes - necessary for Makefile.PL function
-# - # INC => "-I/usr/local/include/io_lib", # leave these as double quotes - necessary for Makefile.PL function
-# - # );
-# - # } or Bio::Root::Root::throw( -class => 'Bio::Root::SystemException',
-# - # -text => "No Inline::C (or maybe io-lib?) support available",
-# - # );
-# - #}
-
-# $VERSION = 1.51;
-
my %formats = ( scf => 1,
abi => 2,
alf => 3,
@@ -130,6 +102,28 @@ sub read_trace {
return @data;
}
+sub read_trace_with_graph
+{
+ my ($self) = shift;
+ my ($fh, $format) = @_;
+
+ unless (exists $formats{$format}) {
+ $self->throw( -class => 'Bio::Root::SystemException',
+ -text => "Format '$format' not supported by Staden read lib",
+ -value => $format
+ );
+ }
+ my @data = $self->staden_read_graph($fh, $formats{$format});
+
+ unless (@data) {
+ $self->throw( -class => 'Bio::Root::SystemException',
+ -text => "Format could not be read - are you sure this is a \"$format\"-formatted trace file?",
+ -value => $format
+ );
+ }
+ return @data;
+}
+
sub write_trace {
my ($self) = shift;
88 Bio/SeqIO/staden/read.xs
View
@@ -149,11 +149,79 @@ void staden_read_trace(SV *self, FILE *fh, int format) {
XSRETURN(4);
}
+void staden_read_graph(SV *self, FILE *fh, int format)
+{
+ dXSARGS;
+
+ Read *read;
+
+ AV *aTrace, *cTrace, *gTrace, *tTrace;
+ SV *aVal, *cVal, *gVal, *tVal, *baseLoc;
+ SV *aRef, *cRef, *gRef, *tRef, *baseRef;
+ AV *baseLocs;
+
+ unsigned short points, location, counter;
+
+ aTrace = newAV();
+ cTrace = newAV();
+ gTrace = newAV();
+ tTrace = newAV();
+ baseLocs = newAV();
+
+ read = fread_reading(fh, (char *) NULL, format);
+
+ if (read == NULLRead)
+ {
+ sp = mark;
+ XPUSHs(&PL_sv_undef);
+ PUTBACK;
+ XSRETURN(1);
+ }
+
+ for (points = 0; points < read->NPoints; points++)
+ {
+ aVal = newSVuv(read->traceA[points]);
+ cVal = newSVuv(read->traceC[points]);
+ gVal = newSVuv(read->traceG[points]);
+ tVal = newSVuv(read->traceT[points]);
+ av_push(aTrace, aVal);
+ av_push(cTrace, cVal);
+ av_push(gTrace, gVal);
+ av_push(tTrace, tVal);
+ }
+
+ for (counter = 0; counter < read->NBases; counter++)
+ {
+ location = read->basePos[counter];
+ baseLoc = newSVuv(location);
+ av_push(baseLocs, baseLoc);
+ }
+
+ aRef = newRV_inc(aTrace);
+ cRef = newRV_inc(cTrace);
+ gRef = newRV_inc(gTrace);
+ tRef = newRV_inc(tTrace);
+ baseRef = newRV_inc(baseLocs);
+
+ sp = mark;
+ XPUSHs(sv_2mortal(baseRef));
+ XPUSHs(sv_2mortal(aRef));
+ XPUSHs(sv_2mortal(cRef));
+ XPUSHs(sv_2mortal(gRef));
+ XPUSHs(sv_2mortal(tRef));
+ XPUSHs(sv_2mortal(newSViv(read->NPoints)));
+ XPUSHs(sv_2mortal(newSViv(read->maxTraceVal)));
+ PUTBACK;
+
+ read_deallocate(read);
+ XSRETURN(7);
+
+}
+
MODULE = Bio::SeqIO::staden::read PACKAGE = Bio::SeqIO::staden::read
PROTOTYPES: DISABLE
-
int
staden_write_trace (self, fh, format, seq, len, qual, id, desc)
SV * self
@@ -183,3 +251,21 @@ staden_read_trace (self, fh, format)
/* must have used dXSARGS; list context implied */
return; /* assume stack size is correct */
+void
+staden_read_graph (self, fh, format)
+ SV * self
+ FILE * fh
+ int format
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ staden_read_graph(self, fh, format);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
Please sign in to comment.
Something went wrong with that request. Please try again.