Exemple #1
0
    def getSketch(self, seq):
        """
		Gets the minhash Sketch for a given sequence
		:param str seq: A DNA sequence
		:return list(int): A list representing the minhash Sketch
		"""
        window = Window(seq, self.word_size, self.N_BUCKETS)
        kmers = window.makeWords(seq)
        return self._min_hash.calcSketch(kmers)
Exemple #2
0
	def getSketch(self, seq):
		"""
		Gets the minhash Sketch for a given sequence
		:param str seq: A DNA sequence
		:return list(int): A list representing the minhash Sketch
		"""
		
		window = Window(seq, self.word_size, 2)
		
	
		pairs = [pair for kmer in window.kmers for pair in window.makeKmerPairs(kmer)]
		return [x[0] for x in self._min_hash.calcSketch(pairs)]
Exemple #3
0
    def test_makePairs(self):
        """Test that the pairs are correctly generated"""
        k1 = KmerSingle(0, 'AA')
        k2 = KmerSingle(1, 'AC')
        k3 = KmerSingle(2, 'CT')

        p1 = KmerPair(k1, k2)
        p2 = KmerPair(k1, k3)
        p3 = KmerPair(k2, k3)

        expect = [p1, p2, p3]
        window = Window("AACT", 2, 2)
        words = window.makeKmerPairs("AACT", 3)
        self.assertTrue(len(expect), len(words))
Exemple #4
0
	def getSketch(self, seq):
		"""
		Gets the minhash Sketch for a given sequence
		:param str seq: A DNA sequence
		:return list(int): A list representing the minhash Sketch
		"""
		
		window = Window(seq, self.word_size, 2)
		
		primary_Sketch = self._min_hash.calcSketch(window.kmers)
		kmer_pairs = []
		
		for min_hash in primary_Sketch:
			kmer_pairs.extend(window.makeKmerPairs(min_hash[1]))
		
		return [x[0] for x in self._min_hash.calcSketch(kmer_pairs)]
Exemple #5
0
	def getSketch(self, seq):
		"""
		Gets the minhash Sketch for a given sequence
		:param str seq: A DNA sequence
		:return list(int): A list representing the minhash Sketch
		"""
		window = Window(seq, self.word_size, 2)
		return [x[0] for x in self._min_hash.calcSketch(window.kmers)]
Exemple #6
0
class TestWindow(unittest.TestCase):
    def setUp(self):
        self.window = Window("AAAT", 2, 2)

    def test_makeWords(self):
        """Test that kmers are generated correctly"""
        kmer_values = ['AA', 'AA', 'AT']
        expect = [KmerSingle(i, x) for i, x in enumerate(kmer_values)]
        words = self.window.makeWords("AAAT")

    def test_makePairs(self):
        """Test that the pairs are correctly generated"""
        k1 = KmerSingle(0, 'AA')
        k2 = KmerSingle(1, 'AC')
        k3 = KmerSingle(2, 'CT')

        p1 = KmerPair(k1, k2)
        p2 = KmerPair(k1, k3)
        p3 = KmerPair(k2, k3)

        expect = [p1, p2, p3]
        window = Window("AACT", 2, 2)
        words = window.makeKmerPairs("AACT", 3)
        self.assertTrue(len(expect), len(words))
Exemple #7
0
 def setUp(self):
     self.window = Window("AAAT", 2, 2)