def test_write_1(self): contact_file = ContactFile("RR") contact_file.target = "R9999" contact_file.author = "1234-5678-9000" contact_file.remark = ["Predictor remarks"] contact_file.method = ["Description of methods used", "Description of methods used"] contact_map = ContactMap("1") contact_file.add(contact_map) for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) contact_map.add(contact) contact_map.sequence = Sequence("1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") contact_map.set_sequence_register() f_name = self.tempfile() with open(f_name, "w") as f_out: MemBrainParser().write(f_out, contact_file) content = [ "Helix Position Residue Helix Position Residue Probability", "Hx 1 H Hx 9 L 0.700000", "Hx 1 H Hx 10 L 0.700000", "Hx 2 L Hx 8 I 0.900000", "Hx 3 E Hx 12 K 0.400000", ] with open(f_name, "r") as f_in: output = f_in.read().splitlines() self.assertEqual(content, output)
def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' contact_file.remark = ['Predictor remarks'] contact_file.method = [ 'Description of methods used', 'Description of methods used' ] contact_map = ContactMap('1') contact_file.add(contact_map) for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) contact_map.add(contact) contact_map.sequence = Sequence('1', 'HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD') contact_map.set_sequence_register() f_name = create_tmp_f() with open(f_name, 'w') as f_out: ComsatParser().write(f_out, contact_file) content = [ "1 H 9 L Hx-Hx", "1 H 10 L Hx-Hx", "2 L 8 I Hx-Hx", "3 E 12 K Hx-Hx", ] with open(f_name, 'r') as f_in: output = f_in.read().splitlines() self.assertEqual(content, output) os.unlink(f_name)
def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' contact_file.remark = ['Predictor remarks'] contact_file.method = ['Description of methods used', 'Description of methods used'] contact_map = ContactMap('1') contact_file.add(contact_map) for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) contact_map.add(contact) contact_map.sequence = Sequence('1', 'HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD') contact_map.assign_sequence_register() f_name = create_tmp_f() with open(f_name, 'w') as f_out: PsicovParser().write(f_out, contact_file) content = [ "1 9 0 8 0.700000", "1 10 0 8 0.700000", "2 8 0 8 0.900000", "3 12 0 8 0.400000", "", ] content = os.linesep.join(content) with open(f_name, 'r') as f_in: data = "".join(f_in.readlines()) self.assertEqual(content, data) os.unlink(f_name)
def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' contact_file.remark = ['Predictor remarks'] contact_file.method = [ 'Description of methods used', 'Description of methods used' ] contact_map = ContactMap('1') contact_file.add(contact_map) for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) contact_map.add(contact) contact_map.sequence = Sequence('sequence_1', 'HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD') contact_map.assign_sequence_register() f_name = create_tmp_f() with open(f_name, 'w') as f_out: PconsParser().write(f_out, contact_file) content = [ "##############################################################################", "PconsC3 result file", "Generated using ConKit", "##############################################################################", "Sequence number: 1", "Sequence name: sequence_1", "Sequence length: 33 aa.", "Sequence:", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD", "", "", "Predicted contacts:", "Res1 Res2 Score", " 1 9 0.700000", " 1 10 0.700000", " 2 8 0.900000", " 3 12 0.400000", "", "##############################################################################", "", ] content = os.linesep.join(content) with open(f_name, 'r') as f_in: data = "".join(f_in.readlines()) self.assertEqual(content, data) os.unlink(f_name)
def test_write_1(self): contact_file = ContactFile("RR") contact_file.target = "R9999" contact_file.author = "1234-5678-9000" contact_file.remark = ["Predictor remarks"] contact_file.method = [ "Description of methods used", "Description of methods used" ] contact_map = ContactMap("1") contact_file.add(contact_map) for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) contact_map.add(contact) contact_map.sequence = Sequence("sequence_1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") contact_map.set_sequence_register() f_name = self.tempfile() with open(f_name, "w") as f_out: PconsParser().write(f_out, contact_file) content = [ "##############################################################################", "PconsC3 result file", "Generated using ConKit", "##############################################################################", "Sequence number: 1", "Sequence name: sequence_1", "Sequence length: 33 aa.", "Sequence:", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD", "", "", "Predicted contacts:", "Res1 Res2 Score", " 1 9 0.700000", " 1 10 0.700000", " 2 8 0.900000", " 3 12 0.400000", "", "##############################################################################", ] with open(f_name, "r") as f_in: output = f_in.read().splitlines() self.assertEqual(content, output)
def test_write_1(self): contact_file = ContactFile("RR") contact_file.target = "R9999" contact_file.author = "1234-5678-9000" contact_file.remark = ["Predictor remarks"] contact_file.method = ["Description of methods used", "Description of methods used"] contact_map = ContactMap("1") contact_file.add(contact_map) for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) contact_map.add(contact) contact_map.sequence = Sequence("1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") contact_map.set_sequence_register() f_name = self.tempfile() with open(f_name, "w") as f_out: ComsatParser().write(f_out, contact_file) content = ["1 H 9 L Hx-Hx", "1 H 10 L Hx-Hx", "2 L 8 I Hx-Hx", "3 E 12 K Hx-Hx"] with open(f_name, "r") as f_in: output = f_in.read().splitlines() self.assertEqual(content, output)
def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' contact_file.remark = ['Predictor remarks'] contact_file.method = [ 'Description of methods used', 'Description of methods used' ] contact_map = ContactMap('1') contact_file.add(contact_map) for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) contact_map.add(contact) contact_map.sequence = Sequence('1', 'HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD') contact_map.set_sequence_register() f_name = create_tmp_f() with open(f_name, 'w') as f_out: CaspParser().write(f_out, contact_file) content = [ "PFRMAT RR", "TARGET R9999", "AUTHOR 1234-5678-9000", "REMARK Predictor remarks", "METHOD Description of methods used", "METHOD Description of methods used", "MODEL 1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD", "1 9 0 8 0.700000", "1 10 0 8 0.700000", "2 8 0 8 0.900000", "3 12 0 8 0.400000", "ENDMDL", "END", ] with open(f_name, 'r') as f_in: output = f_in.read().splitlines() self.assertEqual(content, output) os.unlink(f_name)
def test_target_2(self): contact_file = ContactFile("test") contact_file.target = "John Doe" contact_file.target = "Jane Roe" self.assertEqual("Jane Roe", contact_file.target)