- public static boolean seqIsLikelyToBeAa( final String s ) {
- final String seq = s.toLowerCase();
- if ( ( seq.indexOf( 'r' ) > -1 ) || ( seq.indexOf( 'd' ) > -1 ) || ( seq.indexOf( 'e' ) > -1 )
- || ( seq.indexOf( 'q' ) > -1 ) || ( seq.indexOf( 'h' ) > -1 ) || ( seq.indexOf( 'k' ) > -1 )
- || ( seq.indexOf( 'w' ) > -1 ) || ( seq.indexOf( 's' ) > -1 ) || ( seq.indexOf( 'm' ) > -1 )
- || ( seq.indexOf( 'p' ) > -1 ) || ( seq.indexOf( 'v' ) > -1 ) ) {
- return true;
+ public static String extractGInumber( final PhylogenyNode node ) {
+ String v = null;
+ if ( node.getNodeData().isHasSequence() ) {
+ final Sequence seq = node.getNodeData().getSequence();
+ if ( isEmpty( v ) && !isEmpty( seq.getName() ) ) {
+ v = SequenceIdParser.parseGInumber( seq.getName() );
+ }
+ if ( isEmpty( v ) && ( node.getNodeData().getSequence().getAccession() != null )
+ && !isEmpty( seq.getAccession().getValue() ) ) {
+ v = SequenceIdParser.parseGInumber( seq.getAccession().getValue() );
+ }
+ }
+ if ( isEmpty( v ) && !isEmpty( node.getName() ) ) {
+ v = SequenceIdParser.parseGInumber( node.getName() );
+ }
+ return v;
+ }
+
+ public static String extractUniProtKbProteinSeqIdentifier( final PhylogenyNode node ) {
+ String upkb = null;
+ if ( node.getNodeData().isHasSequence() ) {
+ final Sequence seq = node.getNodeData().getSequence();
+ Matcher m;
+ if ( !isEmpty( seq.getSymbol() ) ) {
+ m = UNIPROT_KB_PATTERN_1.matcher( seq.getSymbol() );
+ if ( m.find() ) {
+ upkb = m.group( 1 );
+ }
+ else {
+ m = UNIPROT_KB_PATTERN_2.matcher( seq.getSymbol() );
+ if ( m.find() ) {
+ upkb = m.group();
+ }
+ }
+ }
+ if ( isEmpty( upkb ) && !isEmpty( seq.getName() ) ) {
+ m = UNIPROT_KB_PATTERN_1.matcher( seq.getName() );
+ if ( m.find() ) {
+ upkb = m.group( 1 );
+ }
+ else {
+ m = UNIPROT_KB_PATTERN_2.matcher( seq.getName() );
+ if ( m.find() ) {
+ upkb = m.group();
+ }
+ }
+ }
+ if ( isEmpty( upkb ) && ( node.getNodeData().getSequence().getAccession() != null )
+ && !isEmpty( seq.getAccession().getValue() ) ) {
+ m = UNIPROT_KB_PATTERN_1.matcher( seq.getAccession().getValue() );
+ if ( m.find() ) {
+ upkb = m.group( 1 );
+ }
+ else {
+ m = UNIPROT_KB_PATTERN_2.matcher( seq.getAccession().getValue() );
+ if ( m.find() ) {
+ upkb = m.group();
+ }
+ }
+ }
+ }
+ if ( isEmpty( upkb ) && !isEmpty( node.getName() ) ) {
+ final Matcher m1 = UNIPROT_KB_PATTERN_1.matcher( node.getName() );
+ if ( m1.find() ) {
+ upkb = m1.group( 1 );
+ }
+ else {
+ final Matcher m2 = UNIPROT_KB_PATTERN_2.matcher( node.getName() );
+ if ( m2.find() ) {
+ upkb = m2.group();
+ }
+ }
+ }
+ return upkb;
+ }
+
+ final public static void appendSeparatorIfNotEmpty( final StringBuffer sb, final char separator ) {
+ if ( sb.length() > 0 ) {
+ sb.append( separator );