# Path: egasub/ega/entities/attribute.py
# class Attribute(object):
#     def __init__(self, tag, value="", unit=None):
#         self.tag = tag
#         self.value = value
#         self.unit = unit
# 
# 
#     def to_dict(self):
#         return {
#             "tag": self.tag,
#             "value": self.value,
#             "unit": self.unit
#         }
# 
# 
#     def to_xml(self):
#         xml_string = "<TAG>%s</TAG>\n<VALUE>%s</VALUE>\n" % (self.tag, self.value)
#         if self.unit is not None:
#             xml_string += "<UNIT>%s</UNIT>\n" % (self.unit)
#         return xml_string
# 
#     @staticmethod
#     def from_dict(attr_dict):
#         return Attribute(attr_dict.get('tag'),attr_dict.get('value'),attr_dict.get('unit'))


from .attribute import Attribute
            'anonymizedName' : self.anonymized_name,
            'bioSampleId' : self.bio_sample_id,
            'sampleAge' : self.sample_age,
            'sampleDetail' : self.sample_detail,
            'attributes' : map(lambda attribute: attribute.to_dict(), self.attributes),
            'id' : self.id,
            'status': self.status,
            'egaAccessionId': self.ega_accession_id
            }

    def to_xml(self):
        pass

    @staticmethod
    def from_dict(sample_dict):
        return Sample(
                    sample_dict.get('alias'),
                    sample_dict.get('title'),
                    sample_dict.get('description'),
                    sample_dict.get('caseOrControlId'),
                    sample_dict.get('genderId'),
                    sample_dict.get('organismPart'),
                    sample_dict.get('cellLine'),
                    sample_dict.get('region'),
                    sample_dict.get('phenotype'),
                    sample_dict.get('subjectId'),
                    sample_dict.get('anonymizedName'),
                    sample_dict.get('bioSampleId'),
                    sample_dict.get('sampleAge'),
                    sample_dict.get('sampleDetail'),

# Path: egasub/ega/entities/attribute.py
# class Attribute(object):
#     def __init__(self, tag, value="", unit=None):
#         self.tag = tag
#         self.value = value
#         self.unit = unit
# 
# 
#     def to_dict(self):
#         return {
#             "tag": self.tag,
#             "value": self.value,
#             "unit": self.unit
#         }
# 
# 
#     def to_xml(self):
#         xml_string = "<TAG>%s</TAG>\n<VALUE>%s</VALUE>\n" % (self.tag, self.value)
#         if self.unit is not None:
#             xml_string += "<UNIT>%s</UNIT>\n" % (self.unit)
#         return xml_string
# 
#     @staticmethod
#     def from_dict(attr_dict):
#         return Attribute(attr_dict.get('tag'),attr_dict.get('value'),attr_dict.get('unit'))


# Path: egasub/ega/entities/sample.py
from .attribute import Attribute

            'anonymizedName' : self.anonymized_name,
            'bioSampleId' : self.bio_sample_id,
            'sampleAge' : self.sample_age,
            'sampleDetail' : self.sample_detail,
            'attributes' : map(lambda attribute: attribute.to_dict(), self.attributes),
            'id' : self.id,
            'status': self.status,
            'egaAccessionId': self.ega_accession_id
            }

    def to_xml(self):
        pass

    @staticmethod
    def from_dict(sample_dict):
        return Sample(
                    sample_dict.get('alias'),
                    sample_dict.get('title'),
                    sample_dict.get('description'),
                    sample_dict.get('caseOrControlId'),
                    sample_dict.get('genderId'),
                    sample_dict.get('organismPart'),
                    sample_dict.get('cellLine'),
                    sample_dict.get('region'),
                    sample_dict.get('phenotype'),
                    sample_dict.get('subjectId'),
                    sample_dict.get('anonymizedName'),
                    sample_dict.get('bioSampleId'),
                    sample_dict.get('sampleAge'),
                    sample_dict.get('sampleDetail'),

                    [] if not sample_dict.get('attributes') else [ Attribute.from_dict(attr_dict) for attr_dict in sample_dict.get('attributes')],