javagene.seq
Class Nucleotide

java.lang.Object
  extended by javagene.seq.Nucleotide

public class Nucleotide
extends java.lang.Object

A nucleotide object, with Dna/Rna utility methods. Understands both the standard A C T G U and the "ambiguous" IUPAC nucleotides, ie, R Y B D H V N.


Nested Class Summary
static class Nucleotide.Type
          Sequence type: DNA or RNA.
 
Field Summary
static Nucleotide A
           
static Nucleotide B
          G or C or T/U (Anything but A).
static Nucleotide C
           
static Nucleotide D
          A or G or T/U (Anything but C).
static Nucleotide G
           
static Nucleotide H
          A or C or T/U (Anything but G).
static Nucleotide N
          Any nucleotide.
static Nucleotide R
          A or G.
static Nucleotide T
           
static Nucleotide U
           
static Nucleotide V
          A or C or G (Anything but T/U).
static Nucleotide Y
          C or T/U.
 
Method Summary
static java.lang.String complement(java.lang.String s, Nucleotide.Type type)
          Complement a string of IUPAC nucleotides.
static java.lang.String dnaComplement(java.lang.String s)
          Complement a string of IUPAC DNA nucleotides (output A C T G only).
static java.lang.String dnaReverseComplement(java.lang.String s)
          Reverse and complement a string of IUPAC DNA nucleotides (A C T G only).
static boolean isComplement(char a, char b)
          Check if two symbols complement one another.
static boolean isWobbleComplement(char a, char b)
          Check if two symbols complement one another, accepting wobble pairs (G-U, G-T) in addition to standard (A-T, A-U, G-C) pairs.
static Nucleotide lookup(java.lang.String str)
          Find the Nucleotide object corresponding to an IUPAC symbol.
 boolean matches(Nucleotide n)
          Check if a Nucleotide object matches this object, allowing ambiguous matches.
 boolean matches(java.lang.String s)
          Check if a IUPAC nucleotide symbol matches this object, allowing ambiguous matches.
static java.lang.String reverseComplement(java.lang.String s, Nucleotide.Type type)
          Reverse and complement a string of IUPAC DNA nucleotides.
static java.lang.String rnaComplement(java.lang.String s)
          Complement a string of IUPAC RNA nucleotides (output A C U G only).
static java.lang.String rnaReverseComplement(java.lang.String s)
          Reverse and complement a string of IUPAC RNA nucleotides (A C U G only).
 java.lang.String toString()
          Get IUPAC representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

A

public static final Nucleotide A

B

public static final Nucleotide B
G or C or T/U (Anything but A).


C

public static final Nucleotide C

D

public static final Nucleotide D
A or G or T/U (Anything but C).


G

public static final Nucleotide G

H

public static final Nucleotide H
A or C or T/U (Anything but G).


N

public static final Nucleotide N
Any nucleotide.


R

public static final Nucleotide R
A or G.


T

public static final Nucleotide T

U

public static final Nucleotide U

V

public static final Nucleotide V
A or C or G (Anything but T/U).


Y

public static final Nucleotide Y
C or T/U.

Method Detail

complement

public static java.lang.String complement(java.lang.String s,
                                          Nucleotide.Type type)
Complement a string of IUPAC nucleotides.

Parameters:
s - The string of one-letter upper or lower case IUPAC nucleotides to complement.
type - Nucleotide.Type.DNA or Nucleotide.Type.RNA.
Returns:
A complemented string. Case is preserved.

dnaComplement

public static java.lang.String dnaComplement(java.lang.String s)
Complement a string of IUPAC DNA nucleotides (output A C T G only).

Parameters:
s - The string of one-letter upper or lower case IUPAC nucleotides to complement.
Returns:
A complemented string, ie A->T, T->A, C->G, G->C, U->A. Case is preserved.

dnaReverseComplement

public static java.lang.String dnaReverseComplement(java.lang.String s)
Reverse and complement a string of IUPAC DNA nucleotides (A C T G only).

Parameters:
s - The string of one-letter upper or lower case IUPAC nucleotides to reverse and complement.
Returns:
The reverse-complemented string, ie A->T, T->A, C->G, G->C. Case is preserved.

isComplement

public static boolean isComplement(char a,
                                   char b)
Check if two symbols complement one another. Accepts only standard (A-T, A-U, G-C) pairs.

Parameters:
a - A nucleotide symbol, either upper or lower case.
b - A nucleotide symbol, either upper or lower case.
Returns:
True if the nucleotides complement one another.

isWobbleComplement

public static boolean isWobbleComplement(char a,
                                         char b)
Check if two symbols complement one another, accepting wobble pairs (G-U, G-T) in addition to standard (A-T, A-U, G-C) pairs.

Parameters:
a - A nucleotide symbol, either upper or lower case.
b - A nucleotide symbol, either upper or lower case.
Returns:
True if the nucleotides complement one another.

lookup

public static Nucleotide lookup(java.lang.String str)
                         throws java.lang.IllegalArgumentException
Find the Nucleotide object corresponding to an IUPAC symbol.

Parameters:
str - One-letter IUPAC nucleotide symbol, either upper or lower case.
Returns:
The corresponding Nucleotide object.
Throws:
java.lang.IllegalArgumentException - The parameter did not match a known nucleotide.

matches

public boolean matches(Nucleotide n)
Check if a Nucleotide object matches this object, allowing ambiguous matches. The nucleotides match if their symbol sets overlap. For example Nucleotide.Y and Nucleotide.T match because Y means "C or T", so "T" is in both sets.

Parameters:
n - The other nucleotide object.
Returns:
True if the two symbol sets overlap.

matches

public boolean matches(java.lang.String s)
Check if a IUPAC nucleotide symbol matches this object, allowing ambiguous matches. The nucleotides match if their symbol sets overlap. For example Nucleotide.Y and symbol "T" match because Y means "C or T", so "T" is in both sets.

Parameters:
s - The one-letter symbol, upper or lower case.
Returns:
True if the two symbol sets overlap.

reverseComplement

public static java.lang.String reverseComplement(java.lang.String s,
                                                 Nucleotide.Type type)
Reverse and complement a string of IUPAC DNA nucleotides.

Parameters:
s - The string of one-letter upper or lower case IUPAC nucleotides to reverse complement.
type - Nucleotide.Type.DNA or Nucleotide.Type.RNA.
Returns:
A complemented string. Case is preserved.

rnaComplement

public static java.lang.String rnaComplement(java.lang.String s)
Complement a string of IUPAC RNA nucleotides (output A C U G only).

Parameters:
s - The string of one-letter upper or lower case IUPAC nucleotides to complement.
Returns:
A complemented string, ie A->U, U->A, C->G, G->C, T->A. Case is preserved.

rnaReverseComplement

public static java.lang.String rnaReverseComplement(java.lang.String s)
Reverse and complement a string of IUPAC RNA nucleotides (A C U G only).

Parameters:
s - The string of one-letter upper or lower case IUPAC nucleotides to reverse and complement.
Returns:
The reverse-complemented string, ie A->U, U->A, C->G, G->C. Case is preserved.

toString

public java.lang.String toString()
Get IUPAC representation.

Overrides:
toString in class java.lang.Object
Returns:
One-letter uppercase IUPAC represenation.