public final static String SEQUENCE_DOMAIN_ARCHITECTURE_PROT_DOMAIN_FROM = "from";
public final static String SEQUENCE_DOMAIN_ARCHITECTURE_PROT_DOMAIN_TO = "to";
public final static String SEQUENCE_DOMAIN_ARCHITECTURE_PROT_DOMAIN_CONFIDENCE = "confidence";
+ public final static String SEQUENCE_X_REFS = "cross_references";
// public final static String NODE_IDENTIFIER = "node_id";
public final static String IDENTIFIER = "id";
public final static String IDENTIFIER_PROVIDER_ATTR = "provider";
public final static String SEQUENCE_RELATION_DISTANCE = "distance";
public final static String SEQUENCE_SOURCE_ID = "id_source";
public final static String POLYGON = "polygon";
+
private PhyloXmlMapping() {
}
public static final String OTHER = "other";
public static final String UNKNOWN = "unknown";
- public final static Pattern SEQUENCE_SYMBOL_PATTERN = Pattern.compile( "\\S{1,20}" );
+ public final static Pattern SEQUENCE_SYMBOL_PATTERN = Pattern.compile( "\\S{1,30}" );
public final static Pattern TAXOMONY_CODE_PATTERN = Pattern
.compile( ParserUtils.TAX_CODE );
public final static Pattern LIT_REF_DOI_PATTERN = Pattern
else if ( child_element.getQualifiedName().equals( PhyloXmlMapping.URI ) ) {
sequence.addUri( ( Uri ) UriParser.getInstance().parse( child_element ) );
}
+ else if ( child_element.getQualifiedName().equals( PhyloXmlMapping.SEQUENCE_X_REFS ) ) {
+ for( int j = 0; j < child_element.getNumberOfChildElements(); ++j ) {
+ // final XmlElement c = child_element.getChildElement( j );
+ sequence.addCrossReference( ( Accession ) AccessionParser.getInstance().parse( child_element.getChildElement( j ) ) );
+ }
+ //sequence.addUri( ( Uri ) UriParser.getInstance().parse( child_element ) );
+ }
}
return sequence;
}
import org.forester.io.parsers.phyloxml.PhyloXmlMapping;
import org.forester.util.ForesterUtil;
-public final class Accession implements PhylogenyData {
+public final class Accession implements PhylogenyData, Comparable<Accession> {
final private String _value;
final private String _source;
- final private String _value_source;
+ final private String _source_value;
public Accession( final String value, final String source ) {
_value = value;
_source = source;
if ( source != null ) {
- _value_source = value + source;
+ _source_value = source + value;
}
else {
- _value_source = value;
+ _source_value = value;
}
}
@Override
public int hashCode() {
- //if ( getSource() != null ) {
- // return ( getSource() + getValue() ).hashCode();
- // }
- return _value_source.hashCode();
+
+ return _source_value.hashCode();
}
@Override
public String toString() {
return asText().toString();
}
+
+ @Override
+ public int compareTo( Accession o ) {
+ if ( equals( o ) ) {
+ return 0;
+ }
+ return _source_value.compareTo( o._source_value );
+ }
}
private DomainArchitecture _da;
private List<Uri> _uris;
private List<SequenceRelation> _seq_relations;
+ private SortedSet<Accession> _xrefs;
public Sequence() {
init();
&& ForesterUtil.isEmpty( getType() ) && ForesterUtil.isEmpty( getLocation() )
&& ForesterUtil.isEmpty( getSourceId() ) && ForesterUtil.isEmpty( getMolecularSequence() )
&& ( getDomainArchitecture() == null ) && ForesterUtil.isEmpty( _annotations )
- && ForesterUtil.isEmpty( _uris ) && ForesterUtil.isEmpty( _seq_relations );
+ && ForesterUtil.isEmpty( _uris ) && ForesterUtil.isEmpty( _seq_relations )
+ && ( getCrossReferences() == null || getCrossReferences().isEmpty() );
}
public void addAnnotation( final Annotation annotation ) {
getAnnotations().add( annotation );
}
+
+ public void addCrossReference( Accession cross_reference ) {
+ if ( getCrossReferences() == null ) {
+ setCrossReferences( new TreeSet<Accession>() );
+ }
+ getCrossReferences().add( cross_reference );
+ }
+
+ public SortedSet<Accession> getCrossReferences() {
+ return _xrefs;
+ }
+
+ private void setCrossReferences( TreeSet<Accession> cross_references ) {
+ _xrefs = cross_references;
+ }
@Override
public void addUri( final Uri uri ) {
else {
seq.setDomainArchitecture( null );
}
+ if ( getCrossReferences() != null ) {
+ seq.setCrossReferences( new TreeSet<Accession>() );
+ for( final Accession x : getCrossReferences() ) {
+ if ( x != null ) {
+ seq.getCrossReferences().add( x);
+ }
+ }
+ }
return seq;
}
setUris( null );
setSequenceRelations( null );
setSourceId( null );
+ setCrossReferences(null);
}
@Override
String.valueOf( isMolecularSequenceAligned() ),
indentation );
}
- if ( getUris() != null ) {
+ if ( getUris() != null && !getUris().isEmpty() ) {
for( final Uri uri : getUris() ) {
if ( uri != null ) {
uri.toPhyloXML( writer, level, indentation );
}
}
}
- if ( _annotations != null ) {
+ if ( getAnnotations() != null && !getAnnotations().isEmpty() ) {
for( final PhylogenyData annotation : getAnnotations() ) {
annotation.toPhyloXML( writer, level, my_ind );
}
if ( getDomainArchitecture() != null ) {
getDomainArchitecture().toPhyloXML( writer, level, my_ind );
}
+ if ( getCrossReferences() != null && !getCrossReferences().isEmpty() ) {
+ writer.write( ForesterUtil.LINE_SEPARATOR );
+ writer.write( my_ind );
+ PhylogenyDataUtil.appendOpen( writer, PhyloXmlMapping.SEQUENCE_X_REFS );
+ for( final PhylogenyData x : getCrossReferences() ) {
+ x.toPhyloXML( writer, level, my_ind );
+ }
+ writer.write( ForesterUtil.LINE_SEPARATOR );
+ writer.write( my_ind );
+ PhylogenyDataUtil.appendClose( writer, PhyloXmlMapping.SEQUENCE_X_REFS );
+ }
writer.write( ForesterUtil.LINE_SEPARATOR );
writer.write( indentation );
PhylogenyDataUtil.appendClose( writer, PhyloXmlMapping.SEQUENCE );
import java.util.List;
import java.util.Locale;
import java.util.Set;
+import java.util.SortedSet;
import org.forester.application.support_transfer;
import org.forester.archaeopteryx.TreePanelUtil;
if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
return false;
}
+ SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
+ if ( x.size() != 4 ) {
+ return false;
+ }
+ int c = 0;
+ for( Accession acc : x ) {
+ if ( c == 0 ) {
+ if ( !acc.getSource().equals( "KEGG" ) ) {
+ return false;
+ }
+ if ( !acc.getValue().equals( "hsa:596" ) ) {
+ return false;
+ }
+ }
+ c++;
+ }
}
catch ( final Exception e ) {
e.printStackTrace( System.out );
}
if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
.getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
- ;
+
return false;
}
if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
.equalsIgnoreCase( "433" ) ) {
return false;
}
+ SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
+ if ( x.size() != 4 ) {
+ return false;
+ }
+ int c = 0;
+ for( Accession acc : x ) {
+ if ( c == 0 ) {
+ if ( !acc.getSource().equals( "KEGG" ) ) {
+ return false;
+ }
+ if ( !acc.getValue().equals( "hsa:596" ) ) {
+ return false;
+ }
+ }
+ c++;
+ }
}
catch ( final Exception e ) {
e.printStackTrace( System.out );
seq.setName( db_entry.getSequenceName() );
}
if ( !ForesterUtil.isEmpty( db_entry.getGeneName() ) ) {
+ final String gn = db_entry.getGeneName().replace( ' ', '_' );
try {
- seq.setSymbol( db_entry.getGeneName() );
+ seq.setSymbol( gn );
}
catch ( PhyloXmlDataFormatException e ) {
// Eat this exception.