crops.core.ops module

Core operations (renumber, crop, split) are defined here.

crop_pdb(instr, inseq, original_id=True)[source]

Return modified gemmi.Structure without specified elements.

Parameters:
  • instr (gemmi.Structure) – Gemmi structure.
  • inseq (crops.elements.sequences.oligoseq) – Input previously-cropped-sequence.
  • original_id (bool, optional) – If True, it will keep residue ids alligned to original sequence, defaults to True.
Returns:

Cropped structure.

Return type:

gemmi.Structure

crop_seq(inseq, segments, cut_type, terms=False)[source]

Return modified crops.elements.sequences.sequence without specified elements.

Parameters:
Raises:

ValueError – If intervals given lie out of the sequence.

Returns:

Cropped sequence.

Return type:

crops.elements.sequences.sequence

get_sequence_alignment(sequence_1, sequence_2, mode='global', open_gap_score=-11, extend_gap_score=-2)[source]

Perform a sequence alignment using Needleman-Wunsch algorithm.

Parameters:
  • sequence_1 (str) – First input sequence.
  • sequence_2 (str) – Second input sequence.
  • mode (str, optional) – Alignment mode, defaults to ‘global’.
  • open_gap_score (int, optional) – Opening gap penalty, defaults to -11.
  • extend_gap_score (int, optional) – Extension gap penalty, defaults to -2.
Return alignment_dict:
 

Dictionary with the residue mapping between both input sequences.

Rtype alignment_dict:
 

dict [int, int]

renumber_pdb(inseq, instr, seqback=False, remove_ligands=False)[source]

Return modified gemmi.Structure with new residue numbers.

Parameters:
  • inseq (crops.elements.sequences.oligoseq) – Input sequence.
  • instr (gemmi.Structure) – Gemmi structure.
  • seqback (bool, optional) – If True, it additionally returns the crops.elements.sequences.oligoseq with the gaps found in the structure, defaults to False.
  • remove_ligands (bool, optional) – If True, use gemmi.Structure.remove_ligands_and_waters() and gemmi.Structure.remove_empty_chains() prior to operation, defaults to False.
Return instr:

Renumbered structure.

Rtype instr:

gemmi.Structure

Return inseq:

Sequence with extra information about gaps, only if seqback is True.

Rtype inseq:

crops.elements.sequences.oligoseq

renumber_pdb_needleman(inseq, instr, seqback=False, remove_ligands=False)[source]

Return modified gemmi.Structure with new residue numbers. It uses Needleman-Wunsch algorithm to perform the sequence alignment.

Parameters:
  • inseq (crops.elements.sequences.oligoseq) – Input sequence.
  • instr (gemmi.Structure) – Gemmi structure.
  • seqback (bool, optional) – If True, it additionally returns the crops.elements.sequences.oligoseq with the gaps found in the structure, defaults to False.
  • remove_ligands (bool, optional) – If True, use gemmi.Structure.remove_ligands_and_waters() and gemmi.Structure.remove_empty_chains() prior to operation, defaults to False.
Return instr:

Renumbered structure.

Rtype instr:

gemmi.Structure

Return inseq:

Sequence with extra information about gaps, only if seqback is True.

Rtype inseq:

crops.elements.sequences.oligoseq