org.strbio.mol
Class Monomer

java.lang.Object
  extended by org.strbio.mol.Monomer
All Implemented Interfaces:
DLinkedList.Node
Direct Known Subclasses:
Nucleotide, Residue

public class Monomer
extends java.lang.Object
implements DLinkedList.Node

Class to represent a single monomer in a linear polymer. Having a monomer that's not part of a polymer doesn't make sense; use Molecule instead.

 Version 1.3, 12/15/04 - added molecularWeight
 Version 1.2, 1/11/00 - added stripAllBut
 Version 1.14, 12/13/99 - added stripAtomsByName
 Version 1.13, 2/16/99 - added YAPF support.  Changed readPDBAtom
   to readAtomRecord to avoid confusion with same function under
   Protein (which does something different), and to be more consistent
   with other readSomethingRecord functions under Residue.
 Version 1.12, 11/2/98 - added isGap, isValidType, isValidNonGap functions
 Version 1.11, 10/26/98 - can read lower case FASTA files
 Version 1.1, 10/16/98 - added centerOfMass()
 Version 1.01, 8/7/98 - changed PrintfStream to Printf
 Version 1.0, 4/16/98 - original version
 

Version:
1.2, 1/11/00
Author:
JMC
See Also:
Atom, AtomNode, Residue, Protein

Field Summary
 DLinkedList atoms
          pointer to the atoms, if there are any (if not, this is null).
 int n
          sequence number, which is the number in the file for files (like PDB) that contain this info; otherwise numbering starts at 0.
 char type
          type of monomer, in a one-letter code
 
Constructor Summary
Monomer()
          Constructor makes everything null.
Monomer(char t)
          Construct from a character with the monomer type.
Monomer(Monomer q)
          copy another monomer, including the atoms.
Monomer(java.lang.String t)
          Construct from a string with the monomer type.
 
Method Summary
 Atom atomSearch(java.lang.String name)
          Search the atoms of this monomer for the first atom with a given name.
 DVector centerOfMass()
          Return a new DVector(3) containing the center of mass for the monomer.
 void centerOfMass(DVector cm)
          Finds the center of mass for the monomer and puts in in the DVector(3) that you pass it.
 void copyAtoms(Monomer q)
          copy the atoms from another monomer.
 void copyDataFrom(Monomer q)
          copy another monomer, including the atoms.
 DLinkedList.Node copyNode()
          copy contents of a monomer.
 boolean isGap()
          does this monomer represent a gap?
 boolean isValidNonGap()
          Is this monomer something which is valid, but not a gap?
 boolean isValidType()
          is the character in 'type' valid for this monomer?
 double molecularWeight()
          molecular weight; default zero.
 int nAtoms()
          How many atoms are there?
 int nAtomsWithCoord()
          How many atoms are there with known coordinates?
 DLinkedList.Node next()
          return the next monomer in the polymer.
 DLinkedList.Node prev()
          return the previous monomer in the polymer.
 void readAtomRecord(java.lang.String buffer)
          Reads one PDB/YAPF atom record out of a buffer string, and inserts it into the list of atoms.
 boolean readFasta(java.io.BufferedReader infile)
          Read this monomer out of a Fasta format file.
 void readSeqRecord(java.lang.String buffer)
          Read this monomer out of a YAPF (sequence profile) format file (JMC's format).
 void rotate(DMatrix rot)
          rotate all atoms by multiplying by a 3x3 rotation matrix.
 void setNext(DLinkedList.Node x)
          set the next monomer in the polymer.
 void setPrev(DLinkedList.Node x)
          set the previous monomer in the polymer.
 void stripAllAtoms()
          Strip away all atoms from this monomer.
 void stripAllBut(java.lang.String[] names)
          Strip away all atoms except ones named in an array.
 void stripAllButFirstAtom()
          Strip all but first atom from this monomer.
 void stripAtomsByName(java.lang.String atomName)
          Strip away a named atom or atoms.
 void transform(DMatrix trans)
          transform the position of all atoms.
 void translate(DVector trans)
          translate all atoms by adding a DVector(3) to their coordinates.
 java.lang.String typeName()
          Return a long name for this monomer, based on the type.
 void writePDBAtom(Printf outfile, java.lang.String polyname, char chainid)
          Writes out PDB ATOM records for all atoms belonging to this monomer.
 void writePts(Printf outfile)
          Writes out this monomer in PTS (Jon Blake's) format.
 void writeSeqRecord(Printf outfile)
          Write this monomer in JMC's YAPF format.
 void writeYAPFAtom(Printf outfile, char chainid)
          Writes out YAPF ATOM records for all atoms belonging to this monomer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

public char type
type of monomer, in a one-letter code


n

public int n
sequence number, which is the number in the file for files (like PDB) that contain this info; otherwise numbering starts at 0. This does not mean that it's the n'th monomer in a list, though!


atoms

public DLinkedList atoms
pointer to the atoms, if there are any (if not, this is null).

Constructor Detail

Monomer

public Monomer()
Constructor makes everything null.


Monomer

public Monomer(char t)
Construct from a character with the monomer type.


Monomer

public Monomer(java.lang.String t)
Construct from a string with the monomer type.


Monomer

public Monomer(Monomer q)
copy another monomer, including the atoms. This makes another copy of the data, but not the links.

Method Detail

copyAtoms

public void copyAtoms(Monomer q)
copy the atoms from another monomer. This makes another copy of the data.


centerOfMass

public DVector centerOfMass()
Return a new DVector(3) containing the center of mass for the monomer. Bug: Atoms don't have atomic weights, so all are treated as the same weight.


centerOfMass

public void centerOfMass(DVector cm)
Finds the center of mass for the monomer and puts in in the DVector(3) that you pass it. Bug: Atoms don't have atomic weights, so all are treated the same. No atoms will return 0,0,0.


nAtoms

public int nAtoms()
How many atoms are there?


nAtomsWithCoord

public int nAtomsWithCoord()
How many atoms are there with known coordinates?


copyDataFrom

public void copyDataFrom(Monomer q)
copy another monomer, including the atoms. This makes another copy of the data, but not the links.


next

public DLinkedList.Node next()
return the next monomer in the polymer.

Specified by:
next in interface DLinkedList.Node

prev

public DLinkedList.Node prev()
return the previous monomer in the polymer.

Specified by:
prev in interface DLinkedList.Node

setNext

public void setNext(DLinkedList.Node x)
set the next monomer in the polymer.

Specified by:
setNext in interface DLinkedList.Node

setPrev

public void setPrev(DLinkedList.Node x)
set the previous monomer in the polymer.

Specified by:
setPrev in interface DLinkedList.Node

copyNode

public DLinkedList.Node copyNode()
copy contents of a monomer.

Specified by:
copyNode in interface DLinkedList.Node

typeName

public java.lang.String typeName()
Return a long name for this monomer, based on the type. The default is to just return a string of whatever's in 'type', but that should be overridden for Residues, Bases, etc. (i.e. 'C' -> "CYS" for Residues).


atomSearch

public final Atom atomSearch(java.lang.String name)
Search the atoms of this monomer for the first atom with a given name. Returns null if there isn't one. Example... to search for the alpha carbon try atomSearch("CA").


stripAllAtoms

public final void stripAllAtoms()
Strip away all atoms from this monomer.


stripAllButFirstAtom

public final void stripAllButFirstAtom()
Strip all but first atom from this monomer.


stripAtomsByName

public final void stripAtomsByName(java.lang.String atomName)
Strip away a named atom or atoms.


stripAllBut

public final void stripAllBut(java.lang.String[] names)
Strip away all atoms except ones named in an array. This is a more general case of Residue.StripAllButCA, but is a bit less efficient due to having to set up the array with multiple names.


writePDBAtom

public void writePDBAtom(Printf outfile,
                         java.lang.String polyname,
                         char chainid)
                  throws java.io.IOException
Writes out PDB ATOM records for all atoms belonging to this monomer.

Parameters:
outfile - an open Printf
polyname - name of the polymer, or null for generic polymer.
chainid - the chain ID, or space if there isn't one.
Throws:
java.io.IOException

writeYAPFAtom

public void writeYAPFAtom(Printf outfile,
                          char chainid)
                   throws java.io.IOException
Writes out YAPF ATOM records for all atoms belonging to this monomer. This is the same as PDB, except without the redundant polymer name info on the right.

Parameters:
outfile - an open Printf
chainid - the chain ID, or space if there isn't one.
Throws:
java.io.IOException

readAtomRecord

public void readAtomRecord(java.lang.String buffer)
Reads one PDB/YAPF atom record out of a buffer string, and inserts it into the list of atoms. This does not set type or number from the record; it's quicker to do this only once, using the first record or a SEQRES entry.

Parameters:
buffer - a line from a PDB/YAPF file with an ATOM record belonging to this monomer.
See Also:
Atom.readPDB(java.lang.String)

writeSeqRecord

public void writeSeqRecord(Printf outfile)
                    throws java.io.IOException
Write this monomer in JMC's YAPF format.

Throws:
java.io.IOException

readSeqRecord

public void readSeqRecord(java.lang.String buffer)
                   throws java.io.IOException
Read this monomer out of a YAPF (sequence profile) format file (JMC's format). The line must be a SEQ N X type line.

Throws:
java.io.IOException

writePts

public void writePts(Printf outfile)
              throws java.io.IOException
Writes out this monomer in PTS (Jon Blake's) format. The coordinates of the first atom in the list are used. You normally want the coordinates of the CA atom, so call stripAllButCA before doing this. If there are no atoms, this function does nothing.

Throws:
java.io.IOException
See Also:
Protein.stripAllButCA(), Polymer.writePTS(org.strbio.io.Printf)

readFasta

public boolean readFasta(java.io.BufferedReader infile)
                  throws java.io.IOException
Read this monomer out of a Fasta format file. It looks through the file for the first character that looks like a residue (letters, '-', '!', and '.'). If it finds one, it upper-cases it, copies it into 'type' and returns true. If it finds a '>' (indicating a new Fasta sequence) it resets the input stream to before the character and returns false. If the end of file is reached without finding either of these things, it returns false.

Throws:
java.io.IOException
See Also:
Polymer.readFasta(java.io.BufferedReader, org.strbio.io.Printf)

translate

public final void translate(DVector trans)
translate all atoms by adding a DVector(3) to their coordinates.

See Also:
Atom.translate(org.strbio.math.DVector)

rotate

public final void rotate(DMatrix rot)
rotate all atoms by multiplying by a 3x3 rotation matrix.

See Also:
Atom.rotate(org.strbio.math.DMatrix)

transform

public final void transform(DMatrix trans)
transform the position of all atoms.

See Also:
Atom.transform(org.strbio.math.DMatrix)

isGap

public boolean isGap()
does this monomer represent a gap?


isValidType

public boolean isValidType()
is the character in 'type' valid for this monomer? Should be overridden for things like residues.


isValidNonGap

public boolean isValidNonGap()
Is this monomer something which is valid, but not a gap?


molecularWeight

public double molecularWeight()
molecular weight; default zero.