コード例 #1
0
ファイル: importancesampling.py プロジェクト: JohnReid/JEMIMA
 def __call__(self, it, importanceratio):
     assert it.repLength >= self.W
     Xn = it.representative[:self.W]
     weight = self.Zncalculator(Xn) * importanceratio
     # If we are sampling unique W-mers rather than occurrences
     # we must multiply by the number of occurrences
     if self.unique:
         weight *= it.numOccurrences
     self.cb(arrayforXn(Xn, weight))
コード例 #2
0
ファイル: importancesampling.py プロジェクト: JohnReid/JEMIMA
 def __call__(self, it, importanceratio):
     assert it.repLength >= self.W
     Xn = it.representative[:self.W]
     weight = self.Zncalculator(Xn) * importanceratio
     # If we are sampling unique W-mers rather than occurrences
     # we must multiply by the number of occurrences
     if self.unique:
         weight *= it.numOccurrences
     self.cb(arrayforXn(Xn, weight))
コード例 #3
0
ファイル: importancesampling.py プロジェクト: JohnReid/JEMIMA
 def __call__(self, it):
     # Always go further than the root
     if 0 == it.repLength:
         return True
     # Don't go any further if we have an unknown base
     if UNKNOWNBASE in parentEdgeLabelUpToW(it, self.W):
         return False
     if it.repLength >= self.W:
         # Get the word
         Xn = it.representative[:self.W]
         # Calculate Zn
         Zn = self.Zncalculator(Xn)
         # Update sums
         self.cb(arrayforXn(Xn, Zn * it.numOccurrences))
         # Have gone deep enough in index, truncate traversal
         return False
     else:
         # Keep descending
         return True
コード例 #4
0
ファイル: importancesampling.py プロジェクト: JohnReid/JEMIMA
 def __call__(self, it):
     # Always go further than the root
     if 0 == it.repLength:
         return True
     # Don't go any further if we have an unknown base
     if UNKNOWNBASE in parentEdgeLabelUpToW(it, self.W):
         return False
     if it.repLength >= self.W:
         # Get the word
         Xn = it.representative[:self.W]
         # Calculate Zn
         Zn = self.Zncalculator(Xn)
         # Update sums
         self.cb(arrayforXn(Xn, Zn * it.numOccurrences))
         # Have gone deep enough in index, truncate traversal
         return False
     else:
         # Keep descending
         return True