Skip to content

Commit

Permalink
solving bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
elowy01 committed Nov 29, 2015
1 parent d20a1c7 commit fd2a989
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 7 deletions.
108 changes: 108 additions & 0 deletions json_schemas/BlueprintSample.schema.dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "A representation of a Blueprint Sample XML",
"type": "object",
"properties": {
"id": {
"type": "string",
"pattern": "^S|^ERS",
"minLength": 4
},
"entity_type": {
"type": "string",
"enum": ["EXPERIMENT","SAMPLE","RUN","STUDY"]

},
"attributes" : {
"type": "array",
"minItems": 2,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"subject_id": {
"type": "string"
},
"MOLECULE": {
"type": "string",
"enum": ["total RNA", "polyA RNA", "cytoplasmic RNA", "nuclear RNA", "genomic DNA", "protein", "other"]
},
"DISEASE": {
"type": "string"
},
"BIOMATERIAL_PROVIDER": {
"type": "string",
"enum": ["NIHR Cambridge BioResource","Jose I. Martin-Subero","Prof: Lucia Altucci (SECONDA UNIVERSITA' di NAPOLI- IT)","Prof.dr. E. Vellenga, University Medical Centre Groningen - Department of Hematology","Sanquin_Nijmegen"]
},
"BIOMATERIAL_TYPE": {
"type": "string",
"enum": ["Cell Line","Primary Cell","Pooled Primary Cell","Primary Tissue"]
},
"CELL_TYPE": {
"type": "string"
},
"TISSUE_TYPE": {
"type": "string"
},
"MARKERS": {
"type": "string",
"pattern": "^CD"
},
"DONOR_ID": {
"type": "string"
},
"DONOR_AGE": {
"type": "string",
"pattern": "[0-9]+-[0-9]+|NA"
},
"DONOR_HEALTH_STATUS": {
"type": "string"
},
"DONOR_SEX": {
"type": "string",
"enum": ["Male","Female","Unknown"]
},
"gender": {
"type": "string",
"enum": ["male","female","unknown"]
},
"DONOR_ETHNICITY": {
"type": "string",
"enum": ["arab","caucasian","dutch","nortern european","NA"]
},
"PASSAGE_IF_EXPANDED": {
"type": "string"
},
"SAMPLE_ONTOLOGY_URI": {
"type": "string",
"pattern": "http://purl.obolibrary.org/obo/+"
},
"DISEASE_ONTOLOGY_URI": {
"type": "string",
"pattern": "^http|NA"
},
"TREATMENT": {
"type": "string"
},
"phenotype": {
"type": "string",
"pattern": "C[0-9]+;CL_[0-9]+;UBERON_[0-9]+"
},
"TISSUE_DEPOT": {
"type": "string"
},
"ENA-CHECKLIST": {
"type": "string",
"pattern": "ERC*"
}
},
"additionalProperties":false
}
]
}
}
},
"required": ["id","entity_type","attributes"]
}
5 changes: 3 additions & 2 deletions lib/Bio/Metadata/Loader/XMLLoaderRole.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ sub load {
$o = $self->hash_to_object($xml_data);
}
elsif ( $root[0] =~ /(.*)_SET/ ) {
my $entities=$xml_data->{$root[0]}->{$1};
$o=$self->array_to_object($entities)
my $entity_type=$1;
my $entities=$xml_data->{$root[0]}->{$entity_type};
$o=$self->array_to_object($entities,$entity_type)
}
# }
# catch {
Expand Down
7 changes: 6 additions & 1 deletion lib/Bio/Metadata/Loader/XMLSampleLoader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use warnings;

use Carp;
use Moose;
use Data::Dumper;
use namespace::autoclean;
use Bio::Metadata::Entity;

Expand Down Expand Up @@ -53,7 +54,7 @@ sub hash_to_object {
}

sub array_to_object {
my ( $self, $array ) = @_;
my ( $self, $array, $type ) = @_;

my @objects;

Expand All @@ -64,6 +65,10 @@ sub array_to_object {
my $id=$sample->{'TITLE'};
$o->id($id);

#set type
$o->entity_type($type);


my $attrb_array=$sample->{'SAMPLE_ATTRIBUTES'}->{'SAMPLE_ATTRIBUTE'};

foreach my $attrb (@$attrb_array) {
Expand Down
1 change: 0 additions & 1 deletion t/.#validate_xml_bp_sampleset.t

This file was deleted.

4 changes: 2 additions & 2 deletions t/data/sample_set.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</SAMPLE_ATTRIBUTE>
<SAMPLE_ATTRIBUTE>
<TAG>DONOR_AGE</TAG>
<VALUE>50 - 55</VALUE>
<VALUE>50-55</VALUE>
</SAMPLE_ATTRIBUTE>
<SAMPLE_ATTRIBUTE>
<TAG>DONOR_HEALTH_STATUS</TAG>
Expand Down Expand Up @@ -108,7 +108,7 @@
</SAMPLE_ATTRIBUTE>
<SAMPLE_ATTRIBUTE>
<TAG>DONOR_AGE</TAG>
<VALUE>50 - 55</VALUE>
<VALUE>50-55</VALUE>
</SAMPLE_ATTRIBUTE>
<SAMPLE_ATTRIBUTE>
<TAG>DONOR_HEALTH_STATUS</TAG>
Expand Down
2 changes: 1 addition & 1 deletion t/validate_xml_bp_sampleset.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use Data::Dumper;
use Test::More;

my $data_dir = "$Bin/data";
my $schema_file="$Bin/../json_schemas/BlueprintSample.schema.json";
my $schema_file="$Bin/../json_schemas/BlueprintSample.schema.dev.json";

my $loader = Bio::Metadata::Loader::XMLSampleLoader->new();

Expand Down

0 comments on commit fd2a989

Please sign in to comment.