def get_align_matrix_from_fname(self, fname):
        """
		2007-03-29
		2007-11-05
			add comment for this function:
				first_block(the reference genome) is used to make sure positions with '-' in the reference would be skipped.
				these '-' don't belong to the reference and they have no corresponding position. if they are not taken out, they
				would cause positions to be offseted.
		"""
        inf = open(fname)
        iter = fasta_block_iterator(inf)
        first_block = iter.next()
        positions_to_be_checked_ls = self.get_positions_to_be_checked_ls(
            first_block)

        align_matrix = []
        abbr_name_ls = []
        for block in iter:
            block = cStringIO.StringIO(block)
            header_line = block.readline()
            abbr_name_ls.append(header_line[1:-1])
            sequence = ''
            for line in block:
                sequence += line[:-1]
            align_one_seq = []
            for i in positions_to_be_checked_ls:
                align_one_seq.append(nt2number[sequence[i]])
            align_matrix.append(align_one_seq)
        del iter
        del inf
        return abbr_name_ls, align_matrix
Exemple #2
0
	def get_align_matrix_from_fname(self, fname):
		"""
		2007-03-29
		2007-11-05
			add comment for this function:
				first_block(the reference genome) is used to make sure positions with '-' in the reference would be skipped.
				these '-' don't belong to the reference and they have no corresponding position. if they are not taken out, they
				would cause positions to be offseted.
		"""
		inf = open(fname)
		iter = fasta_block_iterator(inf)
		first_block = iter.next()
		positions_to_be_checked_ls = self.get_positions_to_be_checked_ls(first_block)
		
		align_matrix = []
		abbr_name_ls = []
		for block in iter:
			block = cStringIO.StringIO(block)
			header_line = block.readline()
			abbr_name_ls.append(header_line[1:-1])
			sequence = ''
			for line in block:
				sequence += line[:-1]
			align_one_seq = []
			for i in positions_to_be_checked_ls:
				align_one_seq.append(nt2number[sequence[i]])
			align_matrix.append(align_one_seq)
		del iter
		del inf
		return abbr_name_ls, align_matrix
Exemple #3
0
	def get_align_length_from_fname(self, fname):
		"""
		2007-03-29
		"""
		inf = open(fname)
		iter = fasta_block_iterator(inf)
		first_block = iter.next()
		positions_to_be_checked_ls = self.get_positions_to_be_checked_ls(first_block)
		del iter
		del inf
		return len(positions_to_be_checked_ls)
    def get_align_length_from_fname(self, fname):
        """
		2007-03-29
		"""
        inf = open(fname)
        iter = fasta_block_iterator(inf)
        first_block = iter.next()
        positions_to_be_checked_ls = self.get_positions_to_be_checked_ls(
            first_block)
        del iter
        del inf
        return len(positions_to_be_checked_ls)