<commit_before>#!/usr/bin/env python

from __future__ import print_function

import os
import sys

# Load the bmrb.py library
if not os.path.isfile("bmrb.py"):
    if not os.path.isfile("../bmrb.py"):
        raise ImportError("Could not locate bmrb.py library. Please copy to this directory.")
    sys.path.append("..")
import bmrb

if len(sys.argv) < 2:
    raise ValueError("You must provide the file to read from as the first argument.")

the_file = sys.argv[1]

if not os.path.isfile(the_file):
    raise IOError("The file you asked to read from does not exist.")
    sys.exit(1)

entry = bmrb.Entry.from_file(the_file)

result = entry.get_tags(["_Entity.Polymer_seq_one_letter_code"])["_Entity.Polymer_seq_one_letter_code"]

if len(result) == 0:
    print("No polymer sequences found in file.")
    sys.exit(2)
elif len(result) > 1:
    sys.stderr.write("Warning: multiple chains in entry.")

for polymer_sequence in result:
    print(polymer_sequence.replace("\n", ""))<commit_msg>Add newline to warning in get_polymer_sequence.<commit_after>#!/usr/bin/env python

from __future__ import print_function

import os
import sys

# Load the bmrb.py library
if not os.path.isfile("bmrb.py"):
    if not os.path.isfile("../bmrb.py"):
        raise ImportError("Could not locate bmrb.py library. Please copy to this directory.")
    sys.path.append("..")
import bmrb

if len(sys.argv) < 2:
    raise ValueError("You must provide the file to read from as the first argument.")

the_file = sys.argv[1]

if not os.path.isfile(the_file):
    raise IOError("The file you asked to read from does not exist.")
    sys.exit(1)

entry = bmrb.Entry.from_file(the_file)

result = entry.get_tags(["_Entity.Polymer_seq_one_letter_code"])["_Entity.Polymer_seq_one_letter_code"]

if len(result) == 0:
    print("No polymer sequences found in file.")
    sys.exit(2)
elif len(result) > 1:
    sys.stderr.write("Warning: multiple chains in entry.\n")

for polymer_sequence in result:
    print(polymer_sequence.replace("\n", ""))
{'fraction_non_alphanumeric': 0.1272365805168986, 'fraction_numerical': 0.005964214711729622, 'mean_word_length': 4.083333333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7463213', 'n_tokens_mistral': 686, 'n_tokens_neox': 672, 'n_words': 193}