From: cmzmasek@gmail.com Date: Fri, 1 Jul 2011 22:52:03 +0000 (+0000) Subject: in progress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c6b74aa20ac0c91099597b9474e7da6c0ffdb9a6;p=jalview.git in progress --- diff --git a/forester/java/src/org/forester/application/pfam_go.java b/forester/java/src/org/forester/application/pfam_go.java index d63ca5f..07e22bb 100644 --- a/forester/java/src/org/forester/application/pfam_go.java +++ b/forester/java/src/org/forester/application/pfam_go.java @@ -29,9 +29,9 @@ import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; import java.util.List; -import java.util.Set; import org.forester.go.PfamToGoMapping; import org.forester.go.PfamToGoParser; @@ -40,20 +40,28 @@ import org.forester.util.ForesterUtil; public class pfam_go { - final static private String HELP_OPTION_1 = "help"; - final static private String HELP_OPTION_2 = "h"; - final static private String PRG_NAME = "pfam_go"; - final static private String PRG_VERSION = "1.00"; - final static private String PRG_DATE = "2010.02.02"; - final static private String E_MAIL = "czmasek@burnham.org"; - final static private String WWW = "www.phylosoft.org"; + private static final String ALLOW_DUPLICATES_OPTION = "d"; + final static private String HELP_OPTION_1 = "help"; + final static private String HELP_OPTION_2 = "h"; + final static private String PRG_NAME = "pfam_go"; + final static private String PRG_VERSION = "1.10"; + final static private String PRG_DATE = "2011.06.26"; + final static private String E_MAIL = "czmasek@burnham.org"; + final static private String WWW = "www.phylosoft.org"; - private static void doit( final File pfams_file, final List mappings ) throws IOException { + private static void process( final File pfams_file, final List mappings, boolean allow_duplicates ) + throws IOException { final BufferedReader reader = ForesterUtil.obtainReader( pfams_file ); String line = ""; int found_count = 0; int not_found_count = 0; - final Set encountered_domains = new HashSet(); + Collection encountered_domains = null; + if ( allow_duplicates ) { + encountered_domains = new ArrayList(); + } + else { + encountered_domains = new HashSet(); + } while ( ( line = reader.readLine() ) != null ) { line = line.trim(); if ( ForesterUtil.isEmpty( line ) || line.startsWith( "##" ) ) { @@ -65,7 +73,7 @@ public class pfam_go { System.out.println( line ); } else { - if ( !encountered_domains.contains( line ) ) { + if ( allow_duplicates || !encountered_domains.contains( line ) ) { encountered_domains.add( line ); boolean found = false; for( final PfamToGoMapping mapping : mappings ) { @@ -104,7 +112,8 @@ public class pfam_go { System.exit( 0 ); } final List allowed_options = new ArrayList(); - if ( cla.getNumberOfNames() != 2 ) { + allowed_options.add( ALLOW_DUPLICATES_OPTION ); + if ( cla.getNumberOfNames() != 2 && cla.getNumberOfNames() != 3 ) { printHelp(); System.exit( -1 ); } @@ -114,6 +123,10 @@ public class pfam_go { } final File pfam2go_file = cla.getFile( 0 ); final File pfams_file = cla.getFile( 1 ); + boolean allow_duplicates = false; + if ( cla.isOptionSet( ALLOW_DUPLICATES_OPTION ) ) { + allow_duplicates = true; + } final PfamToGoParser pfam2go_parser = new PfamToGoParser( pfam2go_file ); List mappings = null; try { @@ -123,7 +136,7 @@ public class pfam_go { e.printStackTrace(); } try { - doit( pfams_file, mappings ); + process( pfams_file, mappings, allow_duplicates ); } catch ( final IOException e ) { e.printStackTrace(); @@ -135,7 +148,8 @@ public class pfam_go { ForesterUtil.printProgramInformation( PRG_NAME, PRG_VERSION, PRG_DATE, E_MAIL, WWW ); System.out.println( "Usage:" ); System.out.println(); - System.out.println( PRG_NAME + " " ); + System.out.println( PRG_NAME + " [-" + ALLOW_DUPLICATES_OPTION + + " to allow duplicates] " ); System.out.println(); System.out.println(); } diff --git a/forester/java/src/org/forester/application/simple_node_processor.java b/forester/java/src/org/forester/application/simple_node_processor.java index 3f713dc..ac60660 100644 --- a/forester/java/src/org/forester/application/simple_node_processor.java +++ b/forester/java/src/org/forester/application/simple_node_processor.java @@ -28,7 +28,6 @@ package org.forester.application; import java.io.File; import org.forester.io.parsers.phyloxml.PhyloXmlParser; -import org.forester.io.writers.PhylogenyWriter; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory; @@ -64,8 +63,8 @@ public class simple_node_processor { processNode( node, i ); i++; } - final PhylogenyWriter writer = new PhylogenyWriter(); - writer.toPhyloXML( out, phylogeny_0, 0 ); + // final PhylogenyWriter writer = new PhylogenyWriter(); + // writer.toPhyloXML( out, phylogeny_0, 0 ); } catch ( final Exception e ) { System.out.println( e.getLocalizedMessage() ); @@ -74,12 +73,19 @@ public class simple_node_processor { } } + // private static void processNode( final PhylogenyNode node, final int i ) { + // node.setDistanceToParent( PhylogenyNode.DISTANCE_DEFAULT ); + // if ( !node.isExternal() ) { + // if ( ( node.getName() == null ) || node.getName().isEmpty() ) { + // node.setName( BASE + i ); + // } + // } + // } private static void processNode( final PhylogenyNode node, final int i ) { - node.setDistanceToParent( PhylogenyNode.DISTANCE_DEFAULT ); - if ( !node.isExternal() ) { - if ( ( node.getName() == null ) || node.getName().isEmpty() ) { - node.setName( BASE + i ); - } + if ( node.isExternal() ) { + String c = "" + node.getNodeData().getBinaryCharacters().getPresentCount(); + String s = node.getNodeData().getTaxonomy().getScientificName(); + System.out.println( s + "\t" + c ); } } } diff --git a/forester/java/src/org/forester/go/etc/MetaOntologizer.java b/forester/java/src/org/forester/go/etc/MetaOntologizer.java index 10ac1fd..21b8dc8 100644 --- a/forester/java/src/org/forester/go/etc/MetaOntologizer.java +++ b/forester/java/src/org/forester/go/etc/MetaOntologizer.java @@ -66,7 +66,10 @@ public class MetaOntologizer { final static private String PRG_NAME = "meta_ontologizer"; private static final boolean VERBOSE = true; //table-a_41_dollo_all_gains_d-Topology-Elim-Bonferroni.txt: - private final static Pattern PATTERN_ONTOLOGIZER_TABLE_OUTPUT = Pattern.compile( ".*table-(.+)_dollo_.*", + //TODO change back + // private final static Pattern PATTERN_ONTOLOGIZER_TABLE_OUTPUT = Pattern.compile( ".*table-(.+)_dollo_.*", + // Pattern.CASE_INSENSITIVE ); //TODO this might need some work... + private final static Pattern PATTERN_ONTOLOGIZER_TABLE_OUTPUT = Pattern.compile( ".*table-(.+)\\.txt", Pattern.CASE_INSENSITIVE ); //TODO this might need some work... private static boolean hasResultsForSpecies( final Map go_id_to_terms, @@ -146,6 +149,9 @@ public class MetaOntologizer { else if ( line.startsWith( "#" ) ) { current_species = new BasicSpecies( line.substring( 1 ) ); speciesto_to_domain_id.put( current_species, new TreeSet() ); + if ( VERBOSE ) { + ForesterUtil.programMessage( PRG_NAME, "saw " + current_species ); + } } else { if ( current_species == null ) { diff --git a/forester/java/src/org/forester/phylogeny/data/NodeVisualization.java b/forester/java/src/org/forester/phylogeny/data/NodeVisualization.java index 7b51574..5375526 100644 --- a/forester/java/src/org/forester/phylogeny/data/NodeVisualization.java +++ b/forester/java/src/org/forester/phylogeny/data/NodeVisualization.java @@ -28,40 +28,36 @@ package org.forester.phylogeny.data; import java.awt.Color; import java.io.IOException; import java.io.Writer; +import java.util.ArrayList; +import java.util.List; -public class NodeVisualization implements PhylogenyData { +import org.forester.phylogeny.data.Property.AppliesTo; - public enum NodeFill { - NONE, GRADIENT, SOLID - } +public class NodeVisualization implements PhylogenyData { - public enum NodeShape { - CIRCLE, RECTANGLE - } private NodeShape _shape; private NodeFill _fill_type; private Color _border_color; private Color _fill_color; private double _size; + private double _transparancy; public NodeVisualization() { - _shape = NodeShape.CIRCLE; - _fill_type = NodeFill.SOLID; - _border_color = null; - _fill_color = null; - _size = 0; + init(); } public NodeVisualization( final NodeShape shape, final NodeFill fill_type, final Color border_color, final Color fill_color, - final double size ) { - _shape = shape; - _fill_type = fill_type; - _border_color = border_color; - _fill_color = fill_color; - _size = size; + final double size, + final double transparancy ) { + setShape( shape ); + setFillType( fill_type ); + setBorderColor( border_color ); + setFillColor( fill_color ); + setSize( size ); + setTransparancy( transparancy ); } @Override @@ -83,7 +79,8 @@ public class NodeVisualization implements PhylogenyData { .getGreen(), getBorderColor().getBlue() ) : null, getFillColor() != null ? new Color( getFillColor().getRed(), getFillColor() .getGreen(), getFillColor().getBlue() ) : null, - getSize() ); + getSize(), + getTransparancy() ); } public Color getBorderColor() { @@ -106,6 +103,19 @@ public class NodeVisualization implements PhylogenyData { return _size; } + public double getTransparancy() { + return _transparancy; + } + + private void init() { + setShape( NodeShape.CIRCLE ); + setFillType( NodeFill.SOLID ); + setBorderColor( null ); + setFillColor( null ); + setSize( 0 ); + setTransparancy( 1 ); + } + @Override public boolean isEqual( final PhylogenyData data ) { throw new UnsupportedOperationException(); @@ -131,6 +141,10 @@ public class NodeVisualization implements PhylogenyData { _size = size; } + public void setTransparancy( final double transparancy ) { + _transparancy = transparancy; + } + @Override public StringBuffer toNHX() { throw new UnsupportedOperationException(); @@ -145,4 +159,25 @@ public class NodeVisualization implements PhylogenyData { public String toString() { return asText().toString(); } + + public enum NodeFill { + NONE, GRADIENT, SOLID + } + + public enum NodeShape { + CIRCLE, RECTANGLE + } + + private List toProperties() { + final List properties = new ArrayList(); + properties.add( new Property( SIZE_REF, String.valueOf( getSize() ), "", SIZE_TYPE, AppliesTo.NODE ) ); + properties.add( new Property( SIZE_REF, String.valueOf( getShape() ), "", SIZE_TYPE, AppliesTo.NODE ) ); + properties.add( new Property( SIZE_REF, String.valueOf( getFillType() ), "", SIZE_TYPE, AppliesTo.NODE ) ); + properties.add( new Property( SIZE_REF, String.valueOf( getTransparancy() ), "", SIZE_TYPE, AppliesTo.NODE ) ); + properties.add( new Property( SIZE_REF, String.valueOf( getFillColor() ), "", SIZE_TYPE, AppliesTo.NODE ) ); + properties.add( new Property( SIZE_REF, String.valueOf( getBorderColor() ), "", SIZE_TYPE, AppliesTo.NODE ) ); + return properties; + } + public static final String SIZE_REF = "aptx_visualiation:node_sise"; + public static final String SIZE_TYPE = "xsd:decimal"; }