def test_annotateDownloadedfile(): structure_name = '2lbk' file_format = 'pdb' file = inputParser.online_input(structure_name=structure_name, file_format=file_format) models = inputParser.annotate_basepairs(file) assert len(models) == 8
def test_pdbListDownloadWithFormat(): structure_name = '2LBK' file_format = 'pdb' file = inputParser.online_input(structure_name=structure_name, file_format=file_format) assert structure_name.lower() in file assert file_format in file with open(file) as f: assert structure_name in f.readline()
def test_properStrandRead(): structure_name = '1ehz' file_format = 'pdb' desired_output = list( 'gCGGAUUUAgCUCAGuuGGGAGAGCgCCAGAcUgAAgAucUGGAGgUCcUGUGuuCGaUCCACAGAAUUCGCACCA' .upper()) file = inputParser.online_input(structure_name=structure_name, file_format=file_format) strand = inputParser.read_models_from_pdb_file(file)[0] assert desired_output == strand['A']
def test_strandLensToughModel(): structure_name = '1ehz' file_format = 'pdb' file = inputParser.online_input(structure_name=structure_name, file_format=file_format) models = inputParser.read_models_from_pdb_file(file) assert 1 == len(models[0].keys()) assert 'G' == models[0]['A'][0] assert 'G' == models[0]['A'][9] for model in models: assert len(model['A']) == 76
def test_strandTwoChains(): structure_name = '2z74' file_format = 'pdb' file = inputParser.online_input(structure_name=structure_name, file_format=file_format) models = inputParser.read_models_from_pdb_file(file) assert len(models[0].keys()) == 2 assert models[0]['A'][0] == 'A' assert models[0]['A'][-1] == 'U' assert models[0]['B'][0] == 'G' assert models[0]['B'][-1] == 'A'
def test_strandLensMultipleModels(): structure_name = '2lbk' file_format = 'pdb' file = inputParser.online_input(structure_name=structure_name, file_format=file_format) models = inputParser.read_models_from_pdb_file(file) assert len(models) == 8 assert models[0]['A'][0] == 'G' assert models[0]['A'][-1] == 'C' for model in models: assert len(model['A']) == 17
def test_build_dot_notation_canonical_only_one_layer(): structure_name = '2lbk' file_format = 'pdb' desired_output = ".(((((.....)))))." file = inputParser.online_input(structure_name=structure_name, file_format=file_format) models = inputParser.read_models_from_pdb_file(file) text_strand = inputParser.build_txt_strand_from_chains(models[0]) base_pairs = inputParser.annotate_basepairs(file) dot_notation = inputParser.make_dot_notation(text_strand, base_pairs[0]) assert desired_output == dot_notation
def test_fix_base_pairs_two_strand_model(): structure_name = '3g78' file_format = 'pdb' file = inputParser.online_input(structure_name=structure_name, file_format=file_format) models = inputParser.read_complete_models(file) base_pairs = inputParser.annotate_basepairs(file)[0] fixed_base_pairs = inputParser.fix_base_pairs(models[0], base_pairs) pair_with_z_strand = [ pair for pair in fixed_base_pairs if pair[1].strand == 'Z' ] assert pair_with_z_strand[0][1].position == 418
def test_get_missing_residues_from_strandA_3G78(): structure_name = '3g78' file_format = 'pdb' desired_count = '-.{[.(.(((<..(((((((((((...(((.......)))..(((((...{{{.{{{...\ )))))..(((...(((..((((.((((((....))))))))))...]>..)))...))).\ ..(((((((((((.(.....)...((((.......(......(...((((((..((((..\ [[[[[.))))...)))).}}}.}}}...))...)......)....)))))))))...)))\ )))...)))))))))))...}))).)(...((((....))))...).......(((.(..\ ..((..........))...))))....(.(((..(((......)))...))).).(((.(\ ((((((((....)))..)))))).)))...----------------------'.count('-') file = inputParser.online_input(structure_name=structure_name, file_format=file_format) missing_residues = inputParser.get_missing_residues_from_pdb(file) assert desired_count == len(missing_residues)
def test_properLongStrandRead(): structure_name = '3g78' file_format = 'pdb' desired_output = list( "uGUGCCCGGCAUGGGUGCAGUCUAUAGGGUGAGAGUCCCGAACUGUGAAGGCAGAAGUA\ ACAGUUAGCCUAACGCAAGGGUGUCCGUGGCGACAUGGAAUCUGAAGGAAGCGGACGGCA\ AACCUUCGGUCUGAGGAACACGAACUUCAUAUGAGGCUAGGUAUCAAUGGAUGAGUUUGC\ AUAACAAAACAAAGUCCUUUCUGCCAAAGUUGGUACAGAGUAAAUGAAGCAGAUUGAUGA\ AGGGAAAGACUGCAUUCUUACCCGGGGAGGUCUGGAAACAGAAGUCAGCAGAAGUCAUAG\ UACCCUGUUCGCAGGGGAAGGACGGAACAAGUAUGGCGUUCGCGCCUAAGCUUGAACCGC\ CGUAUACCGAACGGUACGUACGGUGGUGUG".upper()) file = inputParser.online_input(structure_name=structure_name, file_format=file_format) models = inputParser.read_models_from_pdb_file(file) assert desired_output == models[0]['A']
def test_build_dot_notation_canonical_huge_structure(): structure_name = '3g78' file_format = 'pdb' desired_count = '-.{[.(.(((<..(((((((((((...(((.......)))..(((((...{{{.{{{...\ )))))..(((...(((..((((.((((((....))))))))))...]>..)))...))).\ ..(((((((((((.(.....)...((((.......(......(...((((((..((((..\ [[[[[.))))...)))).}}}.}}}...))...)......)....)))))))))...)))\ )))...)))))))))))...}))).)(...((((....))))...).......(((.(..\ ..((..........))...))))....(.(((..(((......)))...))).).(((.(\ ((((((((....)))..)))))).)))...----------------------.]]]]]...'.count('.') file = inputParser.online_input(structure_name=structure_name, file_format=file_format) models = inputParser.read_complete_models(file) text_strand = inputParser.build_txt_strand_from_chains(models[0]) base_pairs = inputParser.annotate_basepairs(file) fixed_base_pairs = inputParser.fix_base_pairs(models[0], base_pairs[0]) dot_notation = inputParser.make_dot_notation(text_strand, fixed_base_pairs) assert desired_count < dot_notation.count('.')
def test_pdbListDownload(): structure_name = '1FAT' file = inputParser.online_input(structure_name) assert structure_name.lower() in file with open(file) as f: assert structure_name in f.readline()
pretty_print_model(i, joined_chain_model, dot_notation) def mcannotate_part(file_path): """ :rtype: void :param file_path: path to pdb file """ base_pairs = inputParser.annotate_basepairs(file_path) models = inputParser.read_complete_models(file_path) for i, (model, base_pair) in enumerate(zip(models, base_pairs)): fixed_base_pairs = inputParser.fix_base_pairs(model, base_pair) joined_chain_model = inputParser.build_txt_strand_from_chains(model) dot_notation = inputParser.make_dot_notation(joined_chain_model, fixed_base_pairs) pretty_print_model(i, joined_chain_model, dot_notation) if __name__ == '__main__': args = parser.parse_args() prediction_mode = args.prediction_mode filepath = inputParser.online_input(args.structure_name, 'pdb') if prediction_mode == 'nuss': nussinov_part(filepath) elif prediction_mode == 'mcan': mcannotate_part(filepath) else: print("Unrecognized prediction mode!")