<commit_before>from SiteCrypt import PATH2BIOPYTHON

import os, sys, warnings, subprocess
sys.path.append(PATH2BIOPYTHON)
from Bio import PDB
from Bio.Blast import NCBIXML
from Bio.PDB.PDBParser import PDBParser
from Bio.PDB.Polypeptide import PPBuilder
import numpy
import re
import subprocess
from modeller import *
from modeller.automodel import *
from operator import itemgetter


parser = PDBParser()


def get_pdb_seq(pdb, chain):
    '''
    Read a PDB[pdb] input and outputs a sequence of a desired chain(s)[chain].
    '''
    #TODO: implement for a set of chains

    pdbh = open(pdb)
    structure = parser.get_structure("protein", pdb)
    model = structure[0]
    chain = model[chain]

    ppb = PPBuilder()
    print chain
    ss = ppb.build_peptides(chain)
    print ss
    seq = ''.join([str(i.get_sequence()) for i in ss])

    #print [str(i.get_sequence()) for i in ss]

    return seq



def muscleAlign(qSeq, sSeq, pdb, chain):
    '''
    Align two sequences and produce Modeller-compatible output
    '''

    # --- write sequence file
    output = open('sequences.seq','w')
    output.write( '>%s%s\n' % (pdb,chain) )
    output.write( qSeq+'\n' )
    output.write( '>%s%spdb\n' % (pdb,chain) )
    output.write( sSeq )
    output.close()

    # --- align using Muscle
    cmd = ["muscle", "-in", "sequences.seq", "-out", "alignment.ali"]
    print cmd
    prc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
    prc.wait()

    data = open('alignment.ali')
    D = data.read().split('>')<commit_msg>Remove debug prints.<commit_after>from SiteCrypt import PATH2BIOPYTHON

import os, sys, warnings, subprocess
sys.path.append(PATH2BIOPYTHON)
from Bio import PDB
from Bio.Blast import NCBIXML
from Bio.PDB.PDBParser import PDBParser
from Bio.PDB.Polypeptide import PPBuilder
import numpy
import re
import subprocess
from modeller import *
from modeller.automodel import *
from operator import itemgetter


parser = PDBParser()


def get_pdb_seq(pdb, chain):
    '''
    Read a PDB[pdb] input and outputs a sequence of a desired chain(s)[chain].
    '''
    #TODO: implement for a set of chains

    pdbh = open(pdb)
    structure = parser.get_structure("protein", pdb)
    model = structure[0]
    chain = model[chain]

    ppb = PPBuilder()
    ss = ppb.build_peptides(chain)
    seq = ''.join([str(i.get_sequence()) for i in ss])

    #print [str(i.get_sequence()) for i in ss]

    return seq



def muscleAlign(qSeq, sSeq, pdb, chain):
    '''
    Align two sequences and produce Modeller-compatible output
    '''

    # --- write sequence file
    output = open('sequences.seq','w')
    output.write( '>%s%s\n' % (pdb,chain) )
    output.write( qSeq+'\n' )
    output.write( '>%s%spdb\n' % (pdb,chain) )
    output.write( sSeq )
    output.close()

    # --- align using Muscle
    cmd = ["muscle", "-in", "sequences.seq", "-out", "alignment.ali"]
    print cmd
    prc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
    prc.wait()

    data = open('alignment.ali')
    D = data.read().split('>')
{'fraction_non_alphanumeric': 0.13260582010582012, 'fraction_numerical': 0.001984126984126984, 'mean_word_length': 3.309116809116809, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7074431', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1024, 'n_words': 285}