[Biojava-l] is valid character

Richard HOLLAND hollandr at gis.a-star.edu.sg
Wed Sep 7 22:45:04 EDT 2005


Hi Eric,

You can do something like this to check if a particular letter (token)
is in an alphabet:

	Alphabet myAlphabet = ... ; // get your alphabet from somewhere
	SymbolTokenization st = myAlphabet.getTokenization("token");
	String token = "X"; // the token to check for
	boolean alphaContainsToken = true;
	try {
		st.parseToken("X"); // see if your alphabet contains the
letter X
	} catch (IllegalSymbolException e) {
		alphaContainsToken = false;
	}
	if (alphaContainsToken) System.out.println("Alphabet DOES
contain token "+token);
	else System.out.println("Alphabet DOES NOT contain token
"+token);

cheers,
Richard

Richard Holland
Bioinformatics Specialist
GIS extension 8199
---------------------------------------------
This email is confidential and may be privileged. If you are not the
intended recipient, please delete it and notify us immediately. Please
do not copy or use it for any purpose, or disclose its content to any
other person. Thank you.
---------------------------------------------


> -----Original Message-----
> From: biojava-l-bounces at portal.open-bio.org 
> [mailto:biojava-l-bounces at portal.open-bio.org] On Behalf Of 
> Eric Buckley
> Sent: Wednesday, September 07, 2005 10:14 PM
> To: biojava-l at biojava.org
> Subject: [Biojava-l] is valid character
> 
> 
> I was wondering if there is a way to check if a character is 
> valid within an 
> alphabet. For example I want to do some preprocessing on a 
> string before I 
> convert the string to a SymbolList using DNATools. However if 
> an invalid 
> character exists in the string an Exception will be thrown, 
> so I would first 
> like to remove (or replace) all of the invalid characters.
> 
> Eric Buckley
> 
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l at biojava.org
> http://biojava.org/mailman/listinfo/biojava-l
> 



More information about the Biojava-l mailing list