test bioinformatics format convert

From PyPedia
Jump to: navigation, search

Contents

[edit] Documentation

This is a testing function for the bioinformatics_format_convert article. It goes through all possible format conversions that bioinformatics_format_convert can perform.

[edit] Parameters

<inputs>
</inputs>

[edit] Return

[edit] See also

bioinformatics_format_convert

[edit] Code

import StringIO

def test_bioinformatics_format_convert(silent=False):

	types = ['PLINK', 'TPLINK', 'BEAGLE', 'IMPUTE2', 'MERLIN', 'VCF']
	data = [PLINK_sample_data(), TPLINK_sample_data(), BEAGLE_sample_data(), IMPUTE2_sample_data(), MERLIN_sample_data(), VCF_sample_data()]

	for input_index, input_type in enumerate(types):
		for output_type in types:
			sample_data = data[input_index]

			if input_type in ['VCF']:
				input_file_1 = StringIO.StringIO(sample_data)
				input_file_2 = None
			else:
				input_file_1 = StringIO.StringIO(sample_data[0])
				input_file_2 = StringIO.StringIO(sample_data[1])

			output_file_1 = StringIO.StringIO()
			output_file_2 = StringIO.StringIO()

			if not silent:
				print 'Converting: %s ---> %s' % (input_type, output_type)
			bioinformatics_format_convert(
				input_file_1,
				input_file_2,
				input_type,
				output_file_1,
				output_file_2,
				output_type,
				chromosome = '1',
				phenotype = 'phenotype',
				gender = 'gender',
				silent = silent,
				)

			if not silent:
				print output_file_1.getvalue()
				print '-' * 30
				print output_file_2.getvalue()

			input_file_1.close()
			if input_file_2:
				input_file_2.close()
			output_file_1.close()
			output_file_2.close()

[edit] Unit Tests

def uni1():
	test_bioinformatics_format_convert(silent=True)
	return True

[edit] Development Code

def test_bioinformatics_format_convert():
	pass

[edit] Permissions

[edit] Documentation Permissions

Admin

[edit] Code Permissions

Admin

[edit] Unit Tests Permissions

Admin

[edit] Permissions Permissions

Admin

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox