@Override public StringBuffer toNHX() { final StringBuffer sb = new StringBuffer(); if ( getName().length() > 0 ) { sb.append( ":" ); sb.append( NHXtags.GENE_NAME ); sb.append( ForesterUtil.replaceIllegalNhxCharacters( getName() ) ); } if ( getAccession() != null ) { getAccession().toNHX(); } return sb; }
@Override public StringBuffer asSimpleText() { final StringBuffer sb = new StringBuffer(); if ( getAccession() != null ) { sb.append( "[" ); sb.append( getAccession() ); sb.append( "] " ); } if ( !ForesterUtil.isEmpty( getName() ) ) { sb.append( getName() ); sb.append( " " ); } if ( !ForesterUtil.isEmpty( getLocation() ) ) { sb.append( getLocation() ); } return sb; }
@Override public int hashCode() { if ( getAccession() != null ) { return getAccession().hashCode(); } int result = getName().hashCode(); if ( getSymbol().length() > 0 ) { result ^= getName().hashCode(); } if ( getGeneName().length() > 0 ) { result ^= getGeneName().hashCode(); } if ( getMolecularSequence().length() > 0 ) { result ^= getMolecularSequence().hashCode(); } return result; }
final Color calculateSequenceBasedColor( final Sequence seq ) { if ( ForesterUtil.isEmpty( seq.getName() ) ) { return getTreeColorSet().getSequenceColor(); } Color c = null; final String seq_name = seq.getName(); c = getControlPanel().getSequenceColors().get( seq_name ); if ( c == null ) { c = AptxUtil.calculateColorFromString( seq_name, false ); getControlPanel().getSequenceColors().put( seq_name, c ); } return c; }
@Override public boolean isEqual( final PhylogenyData data ) { if ( this == data ) { return true; } final Sequence s = ( Sequence ) data; if ( ( getAccession() != null ) && ( s.getAccession() != null ) ) { return getAccession().isEqual( s.getAccession() ); } return s.getMolecularSequence().equals( getMolecularSequence() ) && s.getName().equals( getName() ) && s.getSymbol().equals( getSymbol() ) && s.getGeneName().equals( getGeneName() ); }
public List<PhylogenyNode> getNodesViaSequenceName( final String seq_name ) { if ( isEmpty() ) { return null; } final List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>(); for( final PhylogenyNodeIterator iter = iteratorPreorder(); iter.hasNext(); ) { final PhylogenyNode n = iter.next(); if ( n.getNodeData().isHasSequence() && n.getNodeData().getSequence().getName().equals( seq_name ) ) { nodes.add( n ); } } return nodes; }
final static boolean isSequenceEmpty( final Sequence seq ) { return ( seq.getAccession() == null ) && ForesterUtil.isEmpty( seq.getName() ) && ForesterUtil.isEmpty( seq.getGeneName() ) && ForesterUtil.isEmpty( seq.getSymbol() ); }
@Override public int compareTo( final Sequence o ) { if ( ( !ForesterUtil.isEmpty( getName() ) ) && ( !ForesterUtil.isEmpty( o.getName() ) ) ) { return getName().compareTo( o.getName() ); } if ( ( !ForesterUtil.isEmpty( getSymbol() ) ) && ( !ForesterUtil.isEmpty( o.getSymbol() ) ) ) { return getSymbol().compareTo( o.getSymbol() ); } if ( ( !ForesterUtil.isEmpty( getGeneName() ) ) && ( !ForesterUtil.isEmpty( o.getGeneName() ) ) ) { return getGeneName().compareTo( o.getGeneName() ); } if ( ( getAccession() != null ) && ( o.getAccession() != null ) && !ForesterUtil.isEmpty( getAccession().getValue() ) && !ForesterUtil.isEmpty( o.getAccession().getValue() ) ) { return getAccession().getValue().compareTo( o.getAccession().getValue() ); } if ( ( !ForesterUtil.isEmpty( getMolecularSequence() ) ) && ( !ForesterUtil.isEmpty( o.getMolecularSequence() ) ) ) { return getMolecularSequence().compareTo( o.getMolecularSequence() ); } return 0; }
private static void addSequence( final DefaultMutableTreeNode top, final Sequence seq, final String name ) { final DefaultMutableTreeNode category = new DefaultMutableTreeNode( name ); top.add( category ); addSubelement( category, SEQ_NAME, seq.getName() ); addSubelement( category, SEQ_SYMBOL, seq.getSymbol() ); addSubelement( category, SEQ_GENE_NAME, seq.getGeneName() ); if ( seq.getAccession() != null ) { addSubelement( category, SEQ_ACCESSION, seq.getAccession().asText().toString() ); } addSubelement( category, SEQ_LOCATION, seq.getLocation() ); addSubelement( category, SEQ_TYPE, seq.getType() ); addSubelement( category, SEQ_MOL_SEQ, seq.getMolecularSequence() ); if ( ( seq.getAnnotations() != null ) && !seq.getAnnotations().isEmpty() ) { addAnnotations( top, seq.getAnnotations(), category ); } if ( ( seq.getCrossReferences() != null ) && !seq.getCrossReferences().isEmpty() ) { addCrossReferences( top, seq.getCrossReferences(), category ); } if ( ( seq.getUris() != null ) && !seq.getUris().isEmpty() ) { addUris( top, seq.getUris(), category ); } }
public boolean isEmpty() { return ( getAccession() == null ) && ForesterUtil.isEmpty( getName() ) && ForesterUtil.isEmpty( getSymbol() ) && ForesterUtil.isEmpty( getGeneName() ) && ForesterUtil.isEmpty( getType() ) && ForesterUtil.isEmpty( getLocation() ) && ForesterUtil.isEmpty( getSourceId() ) && ForesterUtil.isEmpty( getMolecularSequence() ) && ( getDomainArchitecture() == null ) && ForesterUtil.isEmpty( _annotations ) && ForesterUtil.isEmpty( _uris ) && ForesterUtil.isEmpty( _seq_relations ) && ( ( getCrossReferences() == null ) || getCrossReferences().isEmpty() ); }
@Override public int compare( final PhylogenyNode n1, final PhylogenyNode n2 ) { if ( n1.getNodeData().isHasSequence() && n2.getNodeData().isHasSequence() ) { if ( ( !ForesterUtil.isEmpty( n1.getNodeData().getSequence().getName() ) ) && ( !ForesterUtil.isEmpty( n2.getNodeData().getSequence().getName() ) ) ) { return n1.getNodeData().getSequence().getName().toLowerCase() .compareTo( n2.getNodeData().getSequence().getName().toLowerCase() );
acc = new Accession( "", "" ); addSubelementEditable( category, NodePanel.SEQ_NAME, seq.getName(), PHYLOXML_TAG.SEQ_NAME ); addSubelementEditable( category, NodePanel.SEQ_SYMBOL, seq.getSymbol(), PHYLOXML_TAG.SEQ_SYMBOL ); addSubelementEditable( category, NodePanel.SEQ_GENE_NAME, seq.getGeneName(), PHYLOXML_TAG.SEQ_GENE_NAME );
private final static String obtainLabel( final Set<String> labels_set, final PhylogenyNode n ) throws RIOException { String label; if ( n.getNodeData().isHasSequence() && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) { label = n.getNodeData().getSequence().getName(); } else if ( n.getNodeData().isHasSequence() && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) { label = n.getNodeData().getSequence().getSymbol(); } else if ( n.getNodeData().isHasSequence() && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getGeneName() ) ) { label = n.getNodeData().getSequence().getGeneName(); } else if ( !ForesterUtil.isEmpty( n.getName() ) ) { label = n.getName(); } else { throw new RIOException( "node " + n + " has no appropriate label" ); } if ( labels_set.contains( label ) ) { throw new RIOException( "label " + label + " is not unique" ); } return label; }
public final static String obtainGiNumberFromDataFields( final PhylogenyNode n ) { String a = null; if ( n.getNodeData().isHasSequence() ) { final Sequence seq = n.getNodeData().getSequence(); if ( ForesterUtil.isEmpty( a ) && !ForesterUtil.isEmpty( seq.getName() ) ) { a = parseGInumberFromString( seq.getName() ); } if ( ForesterUtil.isEmpty( a ) && !ForesterUtil.isEmpty( seq.getGeneName() ) ) { a = parseGInumberFromString( seq.getGeneName() ); } if ( ForesterUtil.isEmpty( a ) && ( n.getNodeData().getSequence().getAccession() != null ) && !ForesterUtil.isEmpty( seq.getAccession().getValue() ) ) { a = parseGInumberFromString( seq.getAccession().getValue() ); } } if ( ForesterUtil.isEmpty( a ) && !ForesterUtil.isEmpty( n.getName() ) ) { a = parseGInumberFromString( n.getName() ); } return a; }
public final static String obtainRefSeqAccessorFromDataFields( final PhylogenyNode n ) { String a = null; if ( n.getNodeData().isHasSequence() ) { final Sequence seq = n.getNodeData().getSequence(); if ( !ForesterUtil.isEmpty( seq.getSymbol() ) ) { a = parseRefSeqAccessorFromString( seq.getSymbol() ); } if ( !ForesterUtil.isEmpty( seq.getGeneName() ) ) { a = parseRefSeqAccessorFromString( seq.getGeneName() ); } if ( ForesterUtil.isEmpty( a ) && !ForesterUtil.isEmpty( seq.getName() ) ) { a = parseRefSeqAccessorFromString( seq.getName() ); } if ( ForesterUtil.isEmpty( a ) && ( n.getNodeData().getSequence().getAccession() != null ) && !ForesterUtil.isEmpty( seq.getAccession().getValue() ) ) { a = parseRefSeqAccessorFromString( seq.getAccession().getValue() ); } } if ( ForesterUtil.isEmpty( a ) && !ForesterUtil.isEmpty( n.getName() ) ) { a = parseRefSeqAccessorFromString( n.getName() ); } return a; }
public final static String obtainGenbankAccessorFromDataFields( final PhylogenyNode n ) { String a = null; if ( n.getNodeData().isHasSequence() ) { final Sequence seq = n.getNodeData().getSequence(); if ( !ForesterUtil.isEmpty( seq.getSymbol() ) ) { a = parseGenbankAccessorFromString( seq.getSymbol() ); } if ( !ForesterUtil.isEmpty( seq.getGeneName() ) ) { a = parseGenbankAccessorFromString( seq.getGeneName() ); } if ( ForesterUtil.isEmpty( a ) && !ForesterUtil.isEmpty( seq.getName() ) ) { a = parseGenbankAccessorFromString( seq.getName() ); } if ( ForesterUtil.isEmpty( a ) && ( n.getNodeData().getSequence().getAccession() != null ) && !ForesterUtil.isEmpty( seq.getAccession().getValue() ) ) { a = parseGenbankAccessorFromString( seq.getAccession().getValue() ); } } if ( ForesterUtil.isEmpty( a ) && !ForesterUtil.isEmpty( n.getName() ) ) { a = parseGenbankAccessorFromString( n.getName() ); } return a; }
public final static String obtainUniProtAccessorFromDataFields( final PhylogenyNode n ) { String a = null; if ( n.getNodeData().isHasSequence() ) { final Sequence seq = n.getNodeData().getSequence(); if ( !ForesterUtil.isEmpty( seq.getSymbol() ) ) { a = SequenceAccessionTools.parseUniProtAccessorFromString( seq.getSymbol() ); } if ( ForesterUtil.isEmpty( a ) && !ForesterUtil.isEmpty( seq.getName() ) ) { a = SequenceAccessionTools.parseUniProtAccessorFromString( seq.getName() ); } if ( ForesterUtil.isEmpty( a ) && !ForesterUtil.isEmpty( seq.getGeneName() ) ) { a = SequenceAccessionTools.parseUniProtAccessorFromString( seq.getGeneName() ); } if ( ForesterUtil.isEmpty( a ) && ( n.getNodeData().getSequence().getAccession() != null ) && !ForesterUtil.isEmpty( seq.getAccession().getValue() ) ) { a = SequenceAccessionTools.parseUniProtAccessorFromString( seq.getAccession().getValue() ); } } if ( ForesterUtil.isEmpty( a ) && !ForesterUtil.isEmpty( n.getName() ) ) { a = SequenceAccessionTools.parseUniProtAccessorFromString( n.getName() ); } return a; }