Package csb |
[frames] | no frames]

# Package csb

source code

CSB is a high-level, object-oriented library used to solve problems in the field of Computational Structural Biology.

# Introduction

The library is composed of a set of highly branched python packages (namespaces). Some of the packages are meant to be directly used by the clients (core library), while others are utility modules and take part in the development of the library:

1. Core class library -- object-oriented, granular, with an emphasis on design and clean interfaces. A Sequence is not a string, and a Structure is not a dict or list. Naming conventions matter.
2. Application framework -- executable console applications ("protocols"), which consume objects from the core library. The framework ensures that each CSB application is also reusable and can be instantiated as a regular python object without any ugly side effects (sys.exit() and friends). See csb.apps for more details.
3. Test framework -- built on top of the standard unittest as a thin wrapping layer. Provides some sugar like transparent management of test data files, and modular test execution. csb.test will give you all the details.

The core library is roughly composed of:

- bioinformatics API: csb.bio, which includes stuff like csb.bio.io, csb.bio.structure, csb.bio.sequence, csb.bio.hmm
- statistics API: csb.statistics, csb.numeric
- utilities - csb.io, csb.core

# Getting started

Perhaps one of the most frequently used parts of the library is the csb.bio.structure module, which provides the Structure, Chain, Residue and Atom objects. You could easily build a Structure from scratch, but a far more common scenario is parsing a structure from a PDB file using one of the AbstractStructureParsers. All bio IO objects, including the StructureParser factory, are defined in csb.bio.io and sub-packages:

    >>> from csb.bio.io.wwpdb import StructureParser
    >>> p = StructureParser("/some/file/pdb1x80.ent")
    >>> s = p.parse_structure()
    >>> print(s)
    <Structure: 1x80, 2 chains>

The last statement will return a csb.bio.structure.Structure instance, which is a composite hierarchical object:

    >>> for chain_id in s.chains:
            chain = s.chains[chain_id]
            for residue in chain.residues:
                for atom_id in residue.atoms:
                    atom = residue.atoms[atom_id]
                    print(atom.vector)

Some of the inner objects in this hierarchy behave just like dictionaries (but are not):

    >>> s.chains['A']        # access chain A by ID
    <Chain A: Protein>
    >>> s['A']               # the same
    <Chain A: Protein>

Others behave like collections:

    >>> chain.residues[10]               # 1-based access to the residues in the chain
    <ProteinResidue [10]: PRO 10>
    >>> chain[10]                        # 0-based, list-like access
    <ProteinResidue [11]: GLY 11>

But all entities are iterable because they inherit the `items` iterator from AbstractEntity. The above loop can be shortened:

    >>> for chain in s.items:
            for residue in chain.items:
                for atom in residue.items:
                    print(atom.vector)

or even more:

    >>> from csb.bio.structure import Atom
    >>> for atom in s.components(klass=Atom):
            print(atom.vector)

You may also be interested in extracting a sub-chain from this structure:

    >>> s.chains['B'].subregion(3, 20)    # from positions 3 to 20, inclusive
    <Chain B: Protein>

or modifying it in some way, for example, in order to append a new residue, try:

    >>> from csb.bio.structure import ProteinResidue
    >>> from csb.bio.sequence import ProteinAlphabet
    >>> residue = ProteinResidue(401, ProteinAlphabet.ALA)
    >>> s.chains['A'].residues.append(residue)

Finally, you would probably want to save your structure back to a PDB file:

    >>> s.to_pdb('/some/file/name.pdb')

# Where to go from here

If you want to dive into statistics, you could peek inside csb.statistics and its sub-packages. For example, csb.statistics.pdf contains a collection of probability density objects, like Gaussian or Gamma.

But chances are you would first like to try reading some files, so you could start exploring csb.bio.io right now. As we have already seen, csb.bio.io.wwpdb provides PDB Structure parsers, for example csb.bio.io.wwpdb.RegularStructureParser and csb.bio.io.wwpdb.LegacyStructureParser.

csb.bio.io.fasta is all about reading FASTA Sequences and SequenceAlignments. Be sure to check out csb.bio.io.fasta.SequenceParser, csb.bio.io.fasta.SequenceAlignmentReader and csb.bio.io.fasta.StructureAlignmentFactory.

If you are working with HHpred (ProfileHMMs, HHpredHits), then csb.bio.io.hhpred is for you. This package provides csb.bio.io.hhpred.HHProfileParser and csb.bio.io.hhpred.HHOutputParser, which are used to read *.hhm and *.hhr files.

Finally, if you want to make some nice plots with matplotlib, you may like the clean object-oriented interface of our Chart. See csb.io.plots and maybe also csb.io.tsv to get started.

# Development

When contributing code to CSB, please take into account the following:

1. New features or bug fixes should always be accompanied by test cases. Also, always run the complete test suite before committing. For more details on this topic, see csb.test.
2. The source code of CSB must be cross-platform and cross-interpreter compatible. csb.core and csb.io will give you all necessary details on how to use the CSB compatibility layer.

# License

CSB is open source and distributed under OSI-approved MIT license:

       Copyright (c) 2012 Michael Habeck

       Permission is hereby granted, free of charge, to any person obtaining
       a copy of this software and associated documentation files (the
       "Software"), to deal in the Software without restriction, including
       without limitation the rights to use, copy, modify, merge, publish,
       distribute, sublicense, and/or sell copies of the Software, and to
       permit persons to whom the Software is furnished to do so, subject to
       the following conditions:

       The above copyright notice and this permission notice shall be
       included in all copies or substantial portions of the Software.

       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
       EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
       MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
       IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
       CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
       TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
       SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version: 1.2.3.617

Submodules
csb.apps: Root package for all executable CSB client programs. csb.apps.bfit: Python application for robust structure superposition of two structures. csb.apps.bfite: Python application for robust structure superposition of an ensemble of structures. csb.apps.buildhmm: Build an HMM from a FASTA sequence. csb.apps.csfrag: CSfrag: build a dynamic library of analogous fragments, given a list of assigned chemical shifts. csb.apps.embd: Sharpening of EM maps by non-negative blind deconvolution. csb.apps.helloworld: This is a CSB HelloWorld dummy application. csb.apps.hhfrag: HHfrag: build a dynamic variable-length fragment library for protein structure prediction with Rosetta AbInitio. csb.apps.hhsearch: Python bindings for the HHsearch program. csb.apps.precision: Measure the precision and coverage of a fragment library stored in Rosetta NNmake format. csb.apps.promix: ProMix: Take a protein structure ensemble and find a mixture of rigid segments or a mixture of conformers. csb.bio: Core bioinformatics abstractions and I/O. csb.bio.fragments: APIs for working with protein structure fragments and libraries. csb.bio.fragments.rosetta: Rosetta fragment libraries. csb.bio.hmm: HHpred and Hidden Markov Model APIs. csb.bio.hmm.pseudocounts csb.bio.io: I/O for various biological file formats. csb.bio.io.clans: Classes for parsing/manipulating/writing CLANS (by Tancred Frickey) files csb.bio.io.cs: Simple NMR STAR chemical shift readers. csb.bio.io.dssp: DSSP Parser csb.bio.io.fasta: FASTA format sequence I/O. csb.bio.io.hhpred: HHpred-related format parsers. csb.bio.io.mrc: Cryo-EM density map I/O csb.bio.io.noe: Simple XEASY and Sparky peak list parsers. csb.bio.io.procheck: Procheck parser csb.bio.io.psipred: PSIPRED Parser csb.bio.io.svg: Build SVG diagrams from various csb objects. csb.bio.io.vasco: VASCO Chemical Shift format parser. csb.bio.io.whatif: Simple WhatIf/WhatCheck Summary parser csb.bio.io.wwpdb: PDB structure parsers, format builders and database providers. csb.bio.nmr: NMR related objects. csb.bio.sequence: Sequence and sequence alignment APIs. csb.bio.sequence.alignment: Collection of sequence alignment algorithms. csb.bio.structure: 3D and secondary structure APIs. csb.bio.utils: Computational utility functions. csb.build: CSB build related tools and programs. csb.core: Generic containers, data structures and language extensions. csb.io: Generic I/O utility objects. csb.io.plots: Plotting facilities, based on Python's MPL library. csb.io.tsv: Read, query and update textual tables via flexible SQL interface. csb.numeric: Low level numeric / math utility functions. csb.numeric.integrators: provides various integration schemes and an abstract gradient class. csb.statistics: Statistics root package. csb.statistics.ars: Adaptive Rejection Sampling (ARS) csb.statistics.maxent: A Maximum-Entropy model for backbone torsion angles. csb.statistics.mixtures: Mixture models for multi-dimensional data. csb.statistics.pdf: Probability density functions. csb.statistics.pdf.parameterized: Probability density functions with support for shared and computed parameters. csb.statistics.rand: Random number generators csb.statistics.samplers: Defines abstract samplers. csb.statistics.samplers.mc: Abstract Monte Carlo samplers. csb.statistics.samplers.mc.multichain: Implements several extended-ensemble Monte Carlo sampling algorithms. csb.statistics.samplers.mc.neqsteppropagator: Propagator class employing stepwise trajectories as used in the NCMC algorithm (Nilmeier et al., "Nonequilibrium candidate Monte Carlo is an efficient tool for equilibrium simulation", PNAS 2011) csb.statistics.samplers.mc.propagators: Provides various deterministic and stochastic propagators. csb.statistics.samplers.mc.singlechain: Various Monte Carlo equilibrium sampling algorithms, which simulate only one Markov chain. csb.statistics.scalemixture: Approximation of a distribution as a mixture of gaussians with a zero mean but different sigmas csb.statmech: Methods for statistical mechanics csb.statmech.ensembles: Statistical Ensembles csb.statmech.wham: Estimate the free energy and density of states from tempered ensembles using histogram re-weighting. csb.test: This is a top level package, hosting the entire CSB test framework. csb.test.app: CSB Test Runner app.

Classes
| Version CSB version number.