Exemplo n.º 1
0
 def test_magetab2json_convert_e_mexp_31(self):
     actual_json = magetab2json.convert(
         os.path.join(self._magetab_data_dir, 'E-MEXP-31.idf.txt'), )
     with open(os.path.join(self._tmp_dir, 'isa.json'), 'w') as out_fp:
         json.dump(actual_json, out_fp)
     with open(os.path.join(self._tmp_dir, 'isa.json')) as actual_json:
         report = isajson.validate(actual_json)
         self.assertEqual(len(report['errors']), 0)
Exemplo n.º 2
0
 def test_magetab2json_convert_e_mexp_31(self):
     with open(os.path.join(self._magetab_data_dir,
                            'E-MEXP-31.idf.txt')) as idf_fp:
         actual_json = magetab2json.convert(idf_fp, 'protein microarray',
                                            'protein expression profiling')
         json.dump(actual_json,
                   open(os.path.join(self._tmp_dir, 'isa.json'), 'w'))
         with open(os.path.join(self._tmp_dir, 'isa.json')) as actual_json:
             report = isajson.validate(actual_json)
             self.assertEqual(len(report['errors']), 0)
Exemplo n.º 3
0
def getj(arrayexpress_id):
    """
    This function downloads MAGE-TAB content as ISA-JSON from the ArrayExpress FTP site.

    :param ax_experiment_id: Experiment identifier for ArrayExpress study to get, as a str (e.g. E-GEOD-59671)
    :return: ISA-JSON representation of the MAGE-TAB content

    Example usage:
        from isatools.io import ax as AX
        my_json = AX.getj('E-GEOD-59671')
    """
    tmp_dir = tempfile.mkdtemp()
    mage_json = None
    try:
        get(arrayexpress_id=arrayexpress_id, target_dir=tmp_dir)
        mage_json = magetab2json.convert(os.path.join(tmp_dir, "{}.idf.txt".format(arrayexpress_id)))
    except Exception as e:
        log.fatal("Something went wrong: {}".format(e))
    finally:
        shutil.rmtree(tmp_dir)
        return mage_json