Esempio n. 1
0
    def xml2HNautySpeciesDefinitions(self, inputMDLRFile):
        """
        Temporary function for translating xml bng definitions to nautty species definition strings

        it call the nfsim library to get the list of possible complexes in the system, however the function right now
        returns the species in question + all molecule types (if we are sending a lone molecule tye as initialization
        it still returns all molecule types), which means the list requires filterinng. and the filtering
        is not pretty

        How to solve: make it so that nfsim returns a more sensible complex list (filtering out unrelated molecule types) or 
        create a nauty label creation mechanism locally
        """

        #get a bng-xml file
        call([self.config['bionetgen'], '-xml', '-check', inputMDLRFile + '.bngl'])
        #extract seed species defition
        seed, rest = splitBNGXML.extractSeedBNG(inputMDLRFile + '.xml')

        #store xml with non-seed sections and load up nfsim library
        with open(namespace.input + '_total.xml', 'w') as f:
            f.write(rest)
        #load up nfsim library
        self.nfsim.initNFsim(namespace.input + '_total.xml', 0)

        # remove encapsulating tags
        seed = seed[30:-30]
        #get the seed species definitions as a list
        seedDict = self.tokenizeSeedElements(seed)


        nautyDict = {}
        for seed in seedDict:
            #initialize nfsim with each species definition and get back a dirty list where one of the entries is the one we want
            #XXX: i think i've solved it on the nfsim side, double check
            tmpList = self.getNautyString(seedDict[seed])
            #and now filter it out...
            #get species names from species definition string
            speciesNames = self.getNamesFromDefinitionString(seed)
            nautyDict[seed] = [x for x in tmpList if all(y in x for y in speciesNames)][0]

        return nautyDict
Esempio n. 2
0
import xmlrpclib
import splitBNGXML


def getCannonicalLabels(seeds):
    pass

seed, _ = splitBNGXML.extractSeedBNG('example.mdlr.xml')
#print seed




proxy = xmlrpclib.ServerProxy("http://localhost:8080/RPC2")
proxy.nfsim.reset()
#print seed

initMap = {"c:a~NO_STATE!4!2,c:l~NO_STATE!3,c:l~NO_STATE!3!0,m:Lig!2!1,m:Rec!0,":1}
proxy.nfsim.initNauty(initMap)
#proxy.nfsim.step()
#proxy.nfsim.init(seed)
print '---'
print proxy.nfsim.query(2)
print '---'
print proxy.nfsim.query(1)
print proxy.nfsim.printInfo("complex")