import os
import string
from array import array
-from Erange import commoncode
+from erange import commoncode
from cistematic.genomes import Genome
result = ([], 0.0, array("f"), 0.0)
self.assertEquals(result, commoncode.findPeak(hitList, 0, 0))
- hitList= [[4, "+", 0.5]]
+ hitList= [{"start": 4, "sense": "+", "weight": 0.5}]
result = ([6, 7], 1.0, array("f", [0.0, 0.0, 0.1111111119389534, 0.3333333432674408, 0.66666668653488159, 0.8888888955116272, 1.0, 1.0, 0.0, 0.0]), 1.0)
self.assertEquals(result, commoncode.findPeak(hitList, 0, 10))
result = ([6, 7], 0.5, array('f', [0.0, 0.0, 0.0555555559694767, 0.1666666716337204, 0.3333333432674408, 0.4444444477558136, 0.5, 0.5, 0.0, 0.0]), 0.5)
result = ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0.0, array("f", [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), 0.0, 6)
self.assertEquals(result, commoncode.findPeak(hitList, 0, 10, shift="auto", returnShift=True))
- hitList= [[4, "+", 0.5]]
+ hitList= [{"start": 4, "sense": "+", "weight": 0.5}]
result = ([7], 1.0, array('f', [0.0, 0.0, 0.0, 0.0, 0.0, 0.1111111119389534, 0.3333333432674408, 0.66666668653488159, 0.0, 0.0]), 1.0, 3)
self.assertEquals(result, commoncode.findPeak(hitList, 0, 10, shift=3, returnShift=True))
- hitList= [[4, "+", 0.5]]
+ hitList= [{"start": 4, "sense": "+", "weight": 0.5}]
result = ([6, 7], 1.0, array('f', [0.0, 0.0, 0.1111111119389534, 0.3333333432674408, 0.66666668653488159, 0.8888888955116272, 1.0, 1.0, 0.0, 0.0]), 1.0, 1.0)
self.assertEquals(result, commoncode.findPeak(hitList, 0, 10, leftPlus=True))
result = ([7], 1.0, array('f', [0.0, 0.0, 0.0, 0.0, 0.0, 0.1111111119389534, 0.3333333432674408, 0.66666668653488159, 0.0, 0.0]), 1.0, 1.0, 3)
#TODO: write test
def testGetBestShiftForRegion(self):
- hitList = [[14, "-", 1.0], [16, "-", 1.0], [24, "+", 1.0], [26, "+", 10.0]]
+ hitList = [{"start": 14, "sense": "-", "weight": 1.0},
+ {"start": 16, "sense": "-", "weight": 1.0},
+ {"start": 24, "sense": "+", "weight": 1.0},
+ {"start": 26, "sense": "+", "weight": 10.0}
+ ]
self.assertEquals(74, commoncode.getBestShiftForRegion(hitList, 0, 100))
self.assertEquals(16, commoncode.getBestShiftForRegion(hitList, 0, 100, maxShift=30))
self.assertEquals(0, commoncode.getBestShiftForRegion(hitList, 0, 100, maxShift=10))
+ #TODO: write test
+ def testFindPeakSequenceArray(self):
+ pass
+
+
+ #TODO: write test
+ def testGetPeakPositionList(self):
+ pass
+
+
#TODO: write test
def testGetFeaturesByChromDict(self):
firstFeatures = {"I": (4123, 4219, "Y74C9A.3", "R", "3UTR"),
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[1, "+", 1.0]]}
+ hitDict = {"1": [{"start": 1, "sense": "+", "weight": 1.0}]}
result = ({"regionID": [1.0, 0.0, 0.0, 0.0]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")],
"2": [("regionID2", 1, 1000, 1000, "F")]
}
- hitDict = {"1": [[1, "+", 1.0]],
- "2": [[1, "+", 1.0]]
+ hitDict = {"1": [{"start": 1, "sense": "+", "weight": 1.0}],
+ "2": [{"start": 1, "sense": "+", "weight": 1.0}]
}
result = ({"regionID2": [1.0, 0.0, 0.0, 0.0], "regionID": [1.0, 0.0, 0.0, 0.0]}, {"regionID2": 1000, "regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[10, "+", 1.0], [80, "+", 0.5]]}
+ hitDict = {"1": [{"start": 10, "sense": "+", "weight": 1.0}, {"start": 80, "sense": "+", "weight": 0.5}]}
result = ({"regionID": [1.0, 0.0, 0.0, 0.5]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[10, "+", 1.0], [80, "+", 0.5], [15, "+", 1.0]]}
+ hitDict = {"1": [{"start": 10, "sense": "+", "weight": 1.0}, {"start": 80, "sense": "+", "weight": 0.5}, {"start": 15, "sense": "+", "weight": 1.0}]}
result = ({"regionID": [2.0, 0.0, 0.0, 0.5]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[10, "+", 1.0], [80, "+", 0.5], [200, "+", 2.0]]}
+ hitDict = {"1": [{"start": 10, "sense": "+", "weight": 1.0}, {"start": 80, "sense": "+", "weight": 0.5}, {"start": 200, "sense": "+", "weight": 2.0}]}
result = ({"regionID": [1.0, 0.0, 0.0, 0.5]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[1, "+", 1.0]]}
+ hitDict = {"1": [{"start": 1, "sense": "+", "weight": 1.0}]}
regionList = ["regionID"]
result = ({"regionID": [1.0, 0.0, 0.0, 0.0]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, regionList))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[1, "+", 1.0]]}
+ hitDict = {"1": [{"start": 1, "sense": "+", "weight": 1.0}]}
regionList = ["empty region"]
result = ({"empty region": [0.0, 0.0, 0.0, 0.0]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, regionList))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")],
"2": [("regionID2", 1, 1000, 1000, "F")]
}
- hitDict = {"1": [[1, "+", 1.0]],
- "2": [[1, "+", 1.0]]
+ hitDict = {"1": [{"start": 1, "sense": "+", "weight": 1.0}],
+ "2": [{"start": 1, "sense": "+", "weight": 1.0}]
}
regionList = ["regionID", "regionID2"]
result = ({"regionID2": [1.0, 0.0, 0.0, 0.0], "regionID": [1.0, 0.0, 0.0, 0.0]}, {"regionID2": 1000, "regionID": 100})
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")],
"2": [("regionID2", 1, 1000, 1000, "F")]
}
- hitDict = {"1": [[1, "+", 1.0]],
- "2": [[1, "+", 1.0]]
+ hitDict = {"1": [{"start": 1, "sense": "+", "weight": 1.0}],
+ "2": [{"start": 1, "sense": "+", "weight": 1.0}]
}
regionList = ["empty region", "regionID2"]
result = ({"regionID2": [1.0, 0.0, 0.0, 0.0], "empty region": [0.0, 0.0, 0.0, 0.0]}, {"regionID2": 1000, "regionID": 100})
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")],
"2": [("regionID2", 1, 1000, 1000, "F")]
}
- hitDict = {"1": [[1, "+", 1.0]],
- "2": [[1, "+", 1.0]]
+ hitDict = {"1": [{"start": 1, "sense": "+", "weight": 1.0}],
+ "2": [{"start": 1, "sense": "+", "weight": 1.0}]
}
regionList = ["regionID2"]
result = ({"regionID2": [1.0, 0.0, 0.0, 0.0]}, {"regionID2": 1000, "regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, regionList))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[1, "+", 1.0]]}
+ hitDict = {"1": [{"start": 1, "sense": "+", "weight": 1.0}]}
result = ({"regionID": [2.0, 0.0, 0.0, 0.0]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, normalizedTag=2.0))
regionsByChromDict = {"1": [(1, 100, "regionID", 100, "F")]}
- hitDict = {"1": [[1, "+", 1.0]]}
+ hitDict = {"1": [{"start": 1, "sense": "+", "weight": 1.0}]}
result = ({"regionID": [1.0, 0.0, 0.0, 0.0]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, defaultRegionFormat=False))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[10, "+", 1.0]]}
+ hitDict = {"1": [{"start": 10, "sense": "+", "weight": 1.0}]}
fixedFirstBin = 20
result = ({"regionID": [1.0, 0.0, 0.0, 0.0]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, fixedFirstBin=fixedFirstBin))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[10, "+", 1.0]]}
+ hitDict = {"1": [{"start": 10, "sense": "+", "weight": 1.0}]}
fixedFirstBin = 5
result = ({"regionID": [0.0, 1.0, 0.0, 0.0]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, fixedFirstBin=fixedFirstBin))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[10, "+", 1.0], [85, "+", 0.5]]}
+ hitDict = {"1": [{"start": 10, "sense": "+", "weight": 1.0}, {"start": 85, "sense": "+", "weight": 0.5}]}
fixedFirstBin = 20
result = ({"regionID": [1.0, 0.5, 0.0, 0.0]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, fixedFirstBin=fixedFirstBin))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[80, "+", 1.0], [85, "+", 0.5]]}
+ hitDict = {"1": [{"start": 80, "sense": "+", "weight": 1.0}, {"start": 85, "sense": "+", "weight": 0.5}]}
fixedFirstBin = 5
result = ({"regionID": [0.0, 1.5, 0.0, 0.0]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, fixedFirstBin=fixedFirstBin))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[10, "+", 1.0], [85, "+", 0.5]]}
+ hitDict = {"1": [{"start": 10, "sense": "+", "weight": 1.0}, {"start": 85, "sense": "+", "weight": 0.5}]}
binLength = 25
result = ({"regionID": [1.0, 0.0, 0.0, 0.5]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, binLength=binLength))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[10, "+", 1.0], [85, "+", 0.5]]}
+ hitDict = {"1": [{"start": 10, "sense": "+", "weight": 1.0}, {"start": 85, "sense": "+", "weight": 0.5}]}
binLength = 50
result = ({"regionID": [1.0, 0.5, 0.0, 0.0]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, binLength=binLength))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[10, "+", 1.0], [85, "+", 0.5]]}
+ hitDict = {"1": [{"start": 10, "sense": "+", "weight": 1.0}, {"start": 85, "sense": "+", "weight": 0.5}]}
binLength = 15
result = ({"regionID": [1.0, 0.0, 0.0, 0.5]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, binLength=binLength))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "F")]}
- hitDict = {"1": [[10, "+", 1.0], [40, "+", 0.7], [85, "+", 0.5]]}
+ hitDict = {"1": [{"start": 10, "sense": "+", "weight": 1.0}, {"start": 40, "sense": "+", "weight": 0.7}, {"start": 85, "sense": "+", "weight": 0.5}]}
binLength = 15
result = ({"regionID": [1.0, 0.0, 0.7, 0.5]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen, binLength=binLength))
regionsByChromDict = {"1": [("regionID", 1, 100, 100, "R")]}
- hitDict = {"1": [[10, "+", 1.0], [40, "+", 0.7], [85, "+", 0.5]]}
+ hitDict = {"1": [{"start": 10, "sense": "+", "weight": 1.0}, {"start": 40, "sense": "+", "weight": 0.7}, {"start": 85, "sense": "+", "weight": 0.5}]}
result = ({"regionID": [0.5, 0.0, 0.7, 1.0]}, {"regionID": 100})
self.assertEquals(result, commoncode.computeRegionBins(regionsByChromDict, hitDict, bins, readlen))
result = ({"regionID": [0.5, 0.0, 0.7, 1.0]}, {"regionID": 100})