Example #1
0
def mongoDBRead(database, tempFileGenerator=None):
    """Parses an sqg from a database
    """
    #Get the core json sqg object
    jsonSqg = database.sqg.find_one()
    jsonSqg.pop("_id")
    
    #Now add the json array lists
    for arrayListProperties in database.arrayLists.find():
        arrayListProperties = arrayListProperties
        jsonArrayList = [ arrayListProperties, [] ]
        type = arrayListProperties["type"]
        arrayListProperties.pop("type")
        arrayListProperties.pop("_id")
        jsonSqg[type] = jsonArrayList
        if tempFileGenerator != None:
            jsonArrayList.append(tempFileGenerator())
    sqg = makeSqgFromJsonSqg(jsonSqg)
    
    #Now fill in the array lists
    for arrayListProperties in database.arrayLists.find():
        assert "type" in arrayListProperties
        type = arrayListProperties["type"]
        arrayList = sqg.getArrayList(type)
        assert arrayList != None
        for array in database.type.find():
            arrayList.addDict(array)
            
    return sqg
Example #2
0
def main():
	vcf = sqgToVcf(makeSqgFromJsonSqg(json.load(sys.stdin)))
	file = open(vcf.referenceName, "w")
	file.write(vcf.referenceStr())
	file.close()
	file = open("variants.fa", "w")
	file.write(vcf.variantsStr())
	file.close()
Example #3
0
adjacencyEdges.addDict({ "node1":cR, "node2":dL, "overlap":-1})
adjacencyEdges.addDict({ "node1":dR, "node2":_2, "overlap":0})
for node1, node2, overlap in adjacencyEdges:
	print "node1", node1, "node2", node2, "overlap", overlap

mixedSubgraphs = InMemoryArrayList(type="mixedSubgraph")
mixedSubgraphs.getArrayNames()
mixedSubgraphs.getArrayTypes()

mixedSubgraphs.getSharedVariables()

walks = InMemoryArrayList(type="walk", inherits="mixedSubgraph", variables=[ "start", "int", "stop", "int" ], sharedVariables={ "edges":[ "segmentEdge", "adjacencyEdge" ] })
sqg.setArrayList(walks)
walks.getArrayNames()
walks.getArrayTypes()

walks.addDict({ "subgraphName":0, "nodes":[ _1, aL, aR, b1L, b1R, b1L, b1R, cR, cL, b2R, b2L, cL, cR, dL, dR, _2 ], "start":0, "stop":0 })
walks.addDict({ "subgraphName":1, "nodes":[ aL, aR, b1L, b1R, b1L, b1R, cR, cL, b2L, b2R, cL, cR, dL, dR ], "start":3, "stop":10 })

from pysqg.jsonSqg import makeJsonSqgFromSqg
jsonSqg = makeJsonSqgFromSqg(sqg)
print jsonSqg
from pysqg.jsonSqg import makeSqgFromJsonSqg
makeSqgFromJsonSqg(jsonSqg)
makeJsonSqgFromSqg(sqg, putOnDiskArraysInJsonSqg=True)

import os
os.remove("./segmentEdges")
os.remove("./adjacencyEdges")