def _get_md5_of_morphology(m):
    # assert False # Is this Cruft?? Added Jan 2011
    treemd5 = _get_md5_of_section(m._dummysection)
    name_md5 = StrUtils.get_hash_md5(m.name)
    assert not m.metadata
    regions_md5 = ','.join([_get_md5_of_region(region) for region in m.get_regions()])
    return StrUtils.get_hash_md5(treemd5 + name_md5 + regions_md5)
def _get_md5_of_section(s):
    # assert False # Is this Cruft?? Added Jan 2011
    section_string = '%2.2f %2.2f %2.2f %2.2f '
    regions_string = (_get_md5_of_region(s.region) if s.region else '')
    children_string = ','.join([_get_md5_of_section(s) for s in s.children])
    id_string = ('' if not s.idtag else StrUtils.get_hash_md5(s.idtag))

    return StrUtils.get_hash_md5(section_string + regions_string + children_string + id_string)
Ejemplo n.º 3
0
def _get_md5_of_morphology(m):
    # assert False # Is this Cruft?? Added Jan 2011
    treemd5 = _get_md5_of_section(m._dummysection)
    name_md5 = StrUtils.get_hash_md5(m.name)
    assert not m.metadata
    regions_md5 = ','.join(
        [_get_md5_of_region(region) for region in m.get_regions()])
    return StrUtils.get_hash_md5(treemd5 + name_md5 + regions_md5)
Ejemplo n.º 4
0
def _get_md5_of_section(s):
    # assert False # Is this Cruft?? Added Jan 2011
    section_string = '%2.2f %2.2f %2.2f %2.2f '
    regions_string = (_get_md5_of_region(s.region) if s.region else '')
    children_string = ','.join([_get_md5_of_section(s) for s in s.children])
    id_string = ('' if not s.idtag else StrUtils.get_hash_md5(s.idtag))

    return StrUtils.get_hash_md5(section_string + regions_string +
                                 children_string + id_string)
Ejemplo n.º 5
0
    def test1(self):
        swcSrc = """
        1 0 1.0 2.0 3.0 4.0 -1
        2 0 5.0 6.0 7.0 8.0 1
        """

        swcOut = MorphologyArray.fromSWC(StringIO(swcSrc)).to_tree().toSWCStr()

        print "*", StrUtils.strip_comments_and_blank_lines(swcSrc), "*"
        print "*", StrUtils.strip_comments_and_blank_lines(swcOut), "*"
        assert StrUtils.strip_comments_and_blank_lines(swcSrc) == StrUtils.strip_comments_and_blank_lines(swcOut)


        m=MorphologyArray.fromSWC(StringIO(swcSrc))
        s = m.toSWC()
        print s
Ejemplo n.º 6
0
    def get_temporary_filename(cls, suffix='', filedirectory=None):


        rnd_string = "%f%d%s" % (time.time(), random.randint(0, 32000), socket.gethostname())
        from morphforge.core.misc import StrUtils
        filename = 'tmp_%s%s' % (StrUtils.get_hash_md5(rnd_string), suffix)

        filedirectory = filedirectory if filedirectory else cls.get_tmp_path()
        return Join(filedirectory, filename)
Ejemplo n.º 7
0
    def get_temporary_filename(cls, suffix='', filedirectory=None):

        rnd_string = "%f%d%s" % (time.time(), random.randint(
            0, 32000), socket.gethostname())
        from morphforge.core.misc import StrUtils
        filename = 'tmp_%s%s' % (StrUtils.get_hash_md5(rnd_string), suffix)

        filedirectory = filedirectory if filedirectory else cls.get_tmp_path()
        return Join(filedirectory, filename)
Ejemplo n.º 8
0
    def prepare_sim_bundle(cls, sim):

        simstring = cPickle.dumps(sim)
        simmd5sum = StrUtils.get_hash_md5(simstring)

        simloc = LocMgr.get_simulation_tmp_dir() + simmd5sum[0:2]
        simloc = LocMgr.ensure_dir_exists(simloc)
        simfilename = Join(simloc, simmd5sum + cls.simsuffix)

        FileIO.write_to_file(txt=simstring, filename=simfilename)

        bundle = SimMetaDataBundle(sim)
        return bundle
Ejemplo n.º 9
0
    def prepare_sim_bundle(cls, sim):

        simstring = cPickle.dumps(sim)
        simmd5sum = StrUtils.get_hash_md5(simstring)

        simloc = LocMgr.get_simulation_tmp_dir() + simmd5sum[0:2]
        simloc = LocMgr.ensure_dir_exists(simloc)
        simfilename = Join(simloc, simmd5sum + cls.simsuffix)

        FileIO.write_to_file(txt=simstring, filename=simfilename)

        bundle = SimMetaDataBundle(sim)
        return bundle
Ejemplo n.º 10
0
    def get_neuron_suffix(self):

        # Cache the result: (We shouldn't have to do this, but there is a bug
        # with EqnSetChlNeuron::getModFileChangeble(), which is not returning the same thing
        # on each call for some reason.
        if self.cachedNeuronSuffix is None:
            # We take the hash off the parameters that will change the mod-file.
            # This means we don't duplicate millions of mod-files
            mod_file_changeables = self.get_mod_file_changeables()
            mod_file_changeables[None] = str(type(mod_file_changeables).__str__), str(self.__class__.__name__)

            md5 = StrUtils.get_hash_md5(pickle.dumps(sorted(tuple(mod_file_changeables.iteritems()))))
            self.cachedNeuronSuffix = 'MIKETMP%sChl' % md5

        return self.cachedNeuronSuffix
Ejemplo n.º 11
0
    def get_neuron_suffix(self):

        # Cache the result: (We shouldn't have to do this, but there is a bug
        # with EqnSetChlNeuron::getModFileChangeble(), which is not returning the same thing
        # on each call for some reason.
        if self.cachedNeuronSuffix is None:
            # We take the hash off the parameters that will change the mod-file.
            # This means we don't duplicate millions of mod-files
            # print 'At get_neuron_suffix'
            mod_file_changeables = self.get_mod_file_changeables()
            mod_file_changeables[None] = str(type(mod_file_changeables).__str__)

            md5 = StrUtils.get_hash_md5(pickle.dumps(mod_file_changeables))
            self.cachedNeuronSuffix = 'MIKETMP%sChl' % md5

        return self.cachedNeuronSuffix
Ejemplo n.º 12
0
 def __init__(self, sim):
     super(SimMetaDataBundleBase, self).__init__()
     self.sim = sim
     self.simmd5sum = StrUtils.get_hash_md5(cPickle.dumps(sim))
     self.postsimulationactions = []
def _get_md5_of_region(r):
    # assert False # Is this Cruft?? Added Jan 2011
    return StrUtils.get_hash_md5(r.name)
Ejemplo n.º 14
0
 def get_md5_hash(self):
     return StrUtils.get_hash_md5(self.modtxt)
Ejemplo n.º 15
0
 def __init__(self, sim):
     super(SimMetaDataBundleBase, self).__init__()
     self.sim = sim
     self.simmd5sum = StrUtils.get_hash_md5(cPickle.dumps(sim))
     self.postsimulationactions = []
Ejemplo n.º 16
0
 def get_md5_hash(self):
     return StrUtils.get_hash_md5(self.modtxt)
Ejemplo n.º 17
0
def _get_md5_of_region(r):
    # assert False # Is this Cruft?? Added Jan 2011
    return StrUtils.get_hash_md5(r.name)