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;
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<PfamToGoMapping> mappings ) throws IOException {
+ private static void process( final File pfams_file, final List<PfamToGoMapping> 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<String> encountered_domains = new HashSet<String>();
+ Collection<String> encountered_domains = null;
+ if ( allow_duplicates ) {
+ encountered_domains = new ArrayList<String>();
+ }
+ else {
+ encountered_domains = new HashSet<String>();
+ }
while ( ( line = reader.readLine() ) != null ) {
line = line.trim();
if ( ForesterUtil.isEmpty( line ) || line.startsWith( "##" ) ) {
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 ) {
System.exit( 0 );
}
final List<String> allowed_options = new ArrayList<String>();
- if ( cla.getNumberOfNames() != 2 ) {
+ allowed_options.add( ALLOW_DUPLICATES_OPTION );
+ if ( cla.getNumberOfNames() != 2 && cla.getNumberOfNames() != 3 ) {
printHelp();
System.exit( -1 );
}
}
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<PfamToGoMapping> mappings = null;
try {
e.printStackTrace();
}
try {
- doit( pfams_file, mappings );
+ process( pfams_file, mappings, allow_duplicates );
}
catch ( final IOException e ) {
e.printStackTrace();
ForesterUtil.printProgramInformation( PRG_NAME, PRG_VERSION, PRG_DATE, E_MAIL, WWW );
System.out.println( "Usage:" );
System.out.println();
- System.out.println( PRG_NAME + " <pfam2go file> <file with pfams>" );
+ System.out.println( PRG_NAME + " [-" + ALLOW_DUPLICATES_OPTION
+ + " to allow duplicates] <pfam2go file> <file with pfams>" );
System.out.println();
System.out.println();
}
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;
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() );
}
}
+ // 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 );
}
}
}
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<GoId, GoTerm> go_id_to_terms,
else if ( line.startsWith( "#" ) ) {
current_species = new BasicSpecies( line.substring( 1 ) );
speciesto_to_domain_id.put( current_species, new TreeSet<DomainId>() );
+ if ( VERBOSE ) {
+ ForesterUtil.programMessage( PRG_NAME, "saw " + current_species );
+ }
}
else {
if ( current_species == null ) {
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
.getGreen(), getBorderColor().getBlue() ) : null,
getFillColor() != null ? new Color( getFillColor().getRed(), getFillColor()
.getGreen(), getFillColor().getBlue() ) : null,
- getSize() );
+ getSize(),
+ getTransparancy() );
}
public Color getBorderColor() {
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();
_size = size;
}
+ public void setTransparancy( final double transparancy ) {
+ _transparancy = transparancy;
+ }
+
@Override
public StringBuffer toNHX() {
throw new UnsupportedOperationException();
public String toString() {
return asText().toString();
}
+
+ public enum NodeFill {
+ NONE, GRADIENT, SOLID
+ }
+
+ public enum NodeShape {
+ CIRCLE, RECTANGLE
+ }
+
+ private List<Property> toProperties() {
+ final List<Property> properties = new ArrayList<Property>();
+ 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";
}