Bio-MAGETAB

 view release on metacpan or  search on metacpan

t/013_sdrf.t  view on Meta::CPAN


dies_ok( sub{ $sdrf_writer = Bio::MAGETAB::Util::Writer::SDRF->new( filehandle     => $fh,
                                                                    magetab_object => $sdrf,
                                                                    export_version => '1.2' ) },
         'writer fails to instantiate with an invalid export version' );

foreach my $version ( qw( 1.0 1.1 ) ) {
    lives_ok( sub{ $sdrf_writer = Bio::MAGETAB::Util::Writer::SDRF->new( filehandle     => $fh,
                                                                         magetab_object => $sdrf,
                                                                         export_version => $version ) },
              "writer instantiates with export version $version" );
}

lives_ok( sub{ $sdrf_writer->write() }, 'writer outputs SDRF data without crashing' );


#########
# These tests take a long time to run and don't really contribute much.
#add_dummy_objects( $sdrf_reader->get_builder() );
#test_parse( $sdrf_reader );

# These two sets of parse results really ought to look identical.
#is_deeply( $sdrf, $sdrf2, 'SDRF objects agree' );
#########

# FIXME (IMPORTANT!) check the output against what we expect!

# FIXME test with bad SDRF input (unrecognized headers etc.)

# Check that assay comments are being processed correctly.
( $fh, $filename ) = tempfile( UNLINK => 1 );
print $fh join("\t", ('Assay Name', 'Comment[com3]','Technology Type', 'Comment[com1]', 'Comment[com2]')) . "\n";
print $fh join("\t", ('Assay 1', 'com text 3','high throughput seq', 'com text 1', 'com text 2')) . "\n";
close( $fh ) or die("Error closing filehandle: $!");

$sdrf_reader = Bio::MAGETAB::Util::Reader::SDRF->new( uri => $filename );
$sdrf = test_parse( $sdrf_reader );

my $tt = join(";", map { $_->get_value }
                  $sdrf_reader->get_builder()->get_assay({ name => 'Assay 1' })->get_comments());
is( $tt, 'com text 3;com text 1;com text 2', 'Assay comments parsing correctly');

# Check that Array Design REF can be attached to Assay Name.
( $fh, $filename ) = tempfile( UNLINK => 1 );
print $fh join("\t", ('Assay Name', 'Array Design REF','Comment[com1]','Technology Type')) . "\n";
print $fh join("\t", ('Assay 1', 'Design 1','Comment 1', 'tt')) . "\n";
close( $fh ) or die("Error closing filehandle: $!");

$sdrf_reader = Bio::MAGETAB::Util::Reader::SDRF->new( uri => $filename );
$sdrf_reader->get_builder->create_array_design({name => 'Design 1'});
$sdrf = test_parse( $sdrf_reader );

my $assay = $sdrf_reader->get_builder()->get_assay({ name => 'Assay 1' });
my $ad = $assay->get_arrayDesign();
is( $ad->get_name(), 'Design 1', 'Assay Array Design correctly linked' );
is( join(";", map { $_->get_value } $ad->get_comments()), 'Comment 1',
    'Array Design commented correctly');

__DATA__
Source Name	Provider	Characteristics[ OrganismPart ]	Characteristics[DiseaseState]	Term Source REF:test namespace	Term Accession Number	Material Type	Description	Comment[MyNVT]	Sample Name	Characteristics[Age]	Unit[TimeUnit]	Term Source REF	Material ...
my source	the guy in the next room	root	hemophilia	NCI META	CL:111111	organism_part	description_text	mycomment	my sample	6	hours	MO	cell	sample comment value	EXTPRTCL10654	the guy in the next room	total RNA	2007-02-21	This did not happen. I was not h...
my source	the guy in the next room	root	hemophilia	NCI META	CL:111111	organism_part	description_text	mycomment	my sample	6	hours	MO	cell	sample comment value	EXTPRTCL10654	the guy in the next room	total RNA	2007-02-21	This did not happen. I was not h...
sparse source 1			normal		blah blah ignore me										EXTPRTCL10654		polyA RNA					sparse LE Cy5			Cy5		P-XMPL-11	ArrayExpress	sparse hyb		A-TEST-1			sparse scan1	testing.jpg		Data3.txt		TRANPRTCL10656	norm 3		NormData3.txt	pained expression			10	mM...
sparse source 2			normal												EXTPRTCL10654		polyA RNA					sparse LE Cy3			Cy3		P-XMPL-11	ArrayExpress	sparse hyb		A-TEST-1			sparse scan2			Data4.txt		TRANPRTCL10656	norm 3		NormData3.txt	pregnant pause					
sparse source 3			normal												EXTPRTCL10654		polyA RNA					sparse LE biotin			biotin		P-XMPL-11	ArrayExpress	sparse hyb b		A-TEST-1		scanning protocol	sparse scan3	imagefile2.TIFF	a bit blurry			TRANPRTCL10656	norm 4		NormData4.txt	preternatura...



( run in 0.937 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )