Skip to content

Commit

Permalink
Staden_io_lib: Fixed the multi read_read, which gets a file pointer p…
Browse files Browse the repository at this point in the history
…assed in.

               It lacked 2 header files and a Perl test.
  • Loading branch information
pjotrp committed Feb 10, 2010
1 parent 5b88946 commit af6a2cc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/mappings/swig/perl/test/test_staden_io_lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

$datadir = '../../../../test/data/trace';

# Read test data
# Read test data - reading one record from file
$procsrffn = "$datadir/abi3700-ztr/1dJ671C13-2a01.q1c.ztr";
print "Parsing trace file ",$procsrffn;

print "\nTT_ZTR=",$staden_io_lib::TT_ZTR;

$result = staden_io_lib::read_reading($procsrffn,$staden_io_lib::TT_ANY);

print("\nformat=",staden_io_libc::Read_format_get($result));
Expand All @@ -15,9 +16,39 @@

croak('Read test failed') if $result->{NBases} != 766;

# Now write test SCF file
# Now write record to test SCF file
$wresult = staden_io_lib::write_reading('test.scf', $result, 0);
croak('Write test failed') if $wresult != 0 or ! -e 'test.scf';
unlink('test.scf');

# Let's try a multi-read using a stateful file pointer, like the example in
# staden's ./progs/extract_fastq.c. It repeats
#
# Read *r = mfread_reading(mFILE *infp, char *in_file, int format)
#
# over a trace file, opened as
#
# mFile *infp = open_exp_mfile(char *fn, char *path);
#
# or
#
# mFile *infp = open_trace_mfile(char *fn, char *path);
#
# In fact, read_read also uses mfread_read, but only once (see Read.c).
#
# In Perl:

$infp = staden_io_lib::open_exp_mfile($procsrffn,"");
$result = staden_io_lib::mfread_reading($infp,$procsrffn,$staden_io_lib::TT_ANY);
print("\nNBases=",$result->{NBases});
print("\nbase=",staden_io_libc::Read_base_get($result));

# and another time
$result = staden_io_lib::mfread_reading($infp,$procsrffn,$staden_io_lib::TT_ANY);
print("\nNBases=",$result->{NBases});
print("\nbase=",staden_io_libc::Read_base_get($result));

# close the file
staden_io_lib::mfclose($infp);

exit 0;
4 changes: 4 additions & 0 deletions src/mappings/swig/staden_io_lib.i
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

%{
#include <Read.h>
#include <open_trace_file.h>
#include <mFILE.h>
%}

%include <Read.h>
%include <open_trace_file.h>
%include <mFILE.h>

0 comments on commit af6a2cc

Please sign in to comment.