Ejemplo n.º 1
0
                if not os.path.exists(NEXSON_DONE_FILEPATH):
                    dfj = get_ot_study_info_from_nexml(NEXML_FILEPATH,
                                                       nexson_syntax_version=NEXSON_VERSION)
                    out = codecs.open(NEXSON_FILEPATH, 'w', encoding='utf-8')
                    json.dump(dfj, out, indent=0, sort_keys=True)
                    out.write('\n')
                    out.close()
                    out = open(NEXSON_DONE_FILEPATH, 'w')
                    out.write('0\n')
                    out.close()
        except locket.LockError:
            return HTTP(102, "Conversion to NexSON still running")
    if output in ['nexson', 'ot:nexson']:
        response.view = 'generic.json'
        nex = json.load(codecs.open(NEXSON_FILEPATH, 'rU', encoding='utf-8'))
        num_trees = count_num_trees(nex, NEXSON_VERSION)
        r = {'data': nex}
        bundle_properties = json.load(codecs.open(RETURN_ATT_FILEPATH, 'rU', encoding='utf-8'))
        try:
            dd = bundle_properties.get('dataDeposit')
            if dd:
                n = nex.get('nex:nexml') or nex['nex']
                add_resource_meta(n, "ot:dataDeposit", dd, NEXSON_VERSION)
        except:
            pass
        r.update(bundle_properties)
        r['numberOfTrees'] = num_trees
        r['nexml2json'] = NEXSON_VERSION
        read_inp_format = bundle_properties.get('inputFormat', '')
        read_filename = bundle_properties.get('filename', '')
Ejemplo n.º 2
0
                         400,
                         T("Submitted data is not a valid NeXML file, or cannot be converted."
                           ))
                 out = codecs.open(NEXSON_FILEPATH, 'w', encoding='utf-8')
                 json.dump(dfj, out, indent=0, sort_keys=True)
                 out.write('\n')
                 out.close()
                 out = open(NEXSON_DONE_FILEPATH, 'w')
                 out.write('0\n')
                 out.close()
     except locket.LockError:
         return HTTP(102, "Conversion to NexSON still running")
 if output in ['nexson', 'ot:nexson']:
     response.view = 'generic.json'
     nex = json.load(codecs.open(NEXSON_FILEPATH, 'rU', encoding='utf-8'))
     num_trees = count_num_trees(nex, NEXSON_VERSION)
     r = {'data': nex}
     bundle_properties = json.load(
         codecs.open(RETURN_ATT_FILEPATH, 'rU', encoding='utf-8'))
     try:
         dd = bundle_properties.get('dataDeposit')
         if dd:
             n = nex.get('nex:nexml') or nex['nex']
             add_resource_meta(n, "ot:dataDeposit", dd, NEXSON_VERSION)
     except:
         pass
     r.update(bundle_properties)
     r['numberOfTrees'] = num_trees
     r['nexml2json'] = NEXSON_VERSION
     read_inp_format = bundle_properties.get('inputFormat', '')
     read_filename = bundle_properties.get('filename', '')
Ejemplo n.º 3
0
 def testCanCountTrees(self):
     for v in ['0.0', '1.0', '1.2']:
         inp = pathmap.nexson_obj('otu/v{v}.json'.format(v=v))
         self.assertEqual(1, count_num_trees(inp, v))