private Organism getHumanOrganism(DataSet data) throws DataStoreException { String human = "H. Sapiens"; human = human.toLowerCase(); List<Organism> organisms = data.getMediatorProvider().getOrganismMediator().getAllOrganisms(); for (Organism organism : organisms) { String organismName = organism.getName(); String organismAlias = organism.getAlias(); if (organismName.toLowerCase().equals(human) || organismAlias.toLowerCase().equals(human)) { return organism; } } return null; }
public static boolean xor_epoch(Population pop, int generation, String filename) { boolean esito = false; // Evaluate each organism if exist the winner......... boolean win = false; Iterator itr_organism; itr_organism = pop.organisms.iterator(); while (itr_organism.hasNext()) { // point to organism Organism _organism = ((Organism) itr_organism.next()); // evaluate esito = xor_evaluate(_organism); // if is a winner , store a flag if (esito) win = true; } // compute average and max fitness for each species Iterator itr_specie; itr_specie = pop.species.iterator(); while (itr_specie.hasNext()) { Species _specie = ((Species) itr_specie.next()); _specie.compute_average_fitness(); _specie.compute_max_fitness(); } // Only print to file every print_every generations if (win || (generation % Neat.p_print_every) == 0) pop.print_to_file_by_species("c:\\jneat\\dati\\" + filename); // if exist a winner write to file if (win) { int cnt = 0; itr_organism = pop.getOrganisms().iterator(); while (itr_organism.hasNext()) { Organism _organism = ((Organism) itr_organism.next()); if (_organism.winner) { System.out.print("\n -WINNER IS #" + _organism.genome.genome_id); _organism.getGenome().print_to_filename("c:\\jneat\\dati\\xor_win" + cnt); cnt++; } } } // wait an epoch and make a reproductionof the best species pop.epoch(generation); if (win) { System.out.print("\t\t** I HAVE FOUND A CHAMPION **"); return true; } else return false; }
public Organism pickPrey() { Organism preferred = null; // declare a preferred prey int maxpreference = 0; for (Organism potentialPrey : getParent() .getInhabitants()) // cycle through all potential prey (organisms in the same ecosystem) { if (foods.getPrefFor(potentialPrey.getSpecies()) > maxpreference) // if the organism is the most preferred of all encountered so far { preferred = potentialPrey; // set this organism to tne new preferred prey maxpreference = foods.getPrefFor( preferred .getSpecies()); // set its preference to the new maxpreference, for comparison // purposes } } return preferred; // return the preferred organism }
private EnrichmentEngineRequestDto createEnrichmentRequest( RelatedGenesEngineResponseDto response) { if (human.getOntology() == null) { return null; } EnrichmentEngineRequestDto request = new EnrichmentEngineRequestDto(); request.setProgressReporter(NullProgressReporter.instance()); request.setMinCategories(MIN_CATEGORIES); request.setqValueThreshold(Q_VALUE_THRESHOLD); request.setOrganismId(human.getId()); request.setOntologyId(human.getOntology().getId()); Set<Long> nodes = new HashSet<Long>(); for (NetworkDto network : response.getNetworks()) { for (InteractionDto interaction : network.getInteractions()) { nodes.add(interaction.getNodeVO1().getId()); nodes.add(interaction.getNodeVO2().getId()); } } request.setNodes(nodes); return request; }
private RelatedGenesEngineRequestDto createRequest() throws ApplicationException { RelatedGenesEngineRequestDto request = new RelatedGenesEngineRequestDto(); request.setNamespace(GeneMania.DEFAULT_NAMESPACE); request.setOrganismId(human.getId()); request.setInteractionNetworks(collapseNetworks(networks)); Set<Long> nodes = new HashSet<Long>(); for (String geneName : genes) { nodes.add(data.getCompletionProvider(human).getNodeId(geneName)); } request.setPositiveNodes(nodes); request.setLimitResults(geneLimit); request.setCombiningMethod(combiningMethod); request.setScoringMethod(org.genemania.type.ScoringMethod.DISCRIMINANT); return request; }
public static void main(String[] args) { try { Genome g = Organism.findGenome(args[0]); File blasttab = new File(args[1]); ProbesFromPrimers pfp = new ProbesFromPrimers(g, blasttab); Collection<NamedRegion> probes = pfp.parseProbes(); for (NamedRegion probe : probes) { String probeName = probe.getName(); System.out.println( String.format( "%s\t%s\t%d\t%d", probeName, probe.getChrom(), probe.getStart(), probe.getEnd())); } } catch (NotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public void setNetworks(Set<String> n) { Map<InteractionNetworkGroup, Collection<InteractionNetwork>> groupMembers = new HashMap<InteractionNetworkGroup, Collection<InteractionNetwork>>(); Collection<InteractionNetworkGroup> groups = human.getInteractionNetworkGroups(); Set<String> notHandled = n; for (InteractionNetworkGroup group : groups) { if (n.contains(group.getName())) { notHandled.remove(group.getName()); List<InteractionNetwork> networkMembers = new ArrayList<InteractionNetwork>(); Collection<InteractionNetwork> networks = group.getInteractionNetworks(); for (InteractionNetwork network : networks) { networkMembers.add(network); } if (networkMembers.size() > 0) { groupMembers.put(group, networkMembers); } } } networks = groupMembers; }
public void eat(Organism other) { addEnergy(other.getFoodValue()); // increase own energy by amount gained from eating other.die(); // make the other organism die }
/** Insert the method's description here. Creation date: (16/01/2002 9.53.37) */ public static boolean xor_evaluate(Organism organism) { Network _net = null; boolean success = false; double errorsum = 0.0; double[] out = new double[4]; // The four outputs // int numnodes = 0; int net_depth = 0; // The max depth of the network to be activated int count = 0; // The four possible input combinations to xor // The first number is for biasing double in[][] = {{1.0, 0.0, 0.0}, {1.0, 0.0, 1.0}, {1.0, 1.0, 0.0}, {1.0, 1.0, 1.0}}; _net = organism.net; // numnodes = organism.genome.nodes.size(); net_depth = _net.max_depth(); // for each example , 'count', propagate signal .... and compute results for (count = 0; count <= 3; count++) { // first activation from sensor to first next levelof neurons _net.load_sensors(in[count]); success = _net.activate(); // next activation while last level is reached ! // use depth to ensure relaxation for (int relax = 0; relax <= net_depth; relax++) success = _net.activate(); // ok : the propagation is completed : repeat until all examples are presented out[count] = ((NNode) _net.getOutputs().firstElement()).getActivation(); _net.flush(); } // control the result if (success) { errorsum = (double) (Math.abs(out[0]) + Math.abs(1.0 - out[1]) + Math.abs(1.0 - out[2]) + Math.abs(out[3])); organism.setFitness(Math.pow((4.0 - errorsum), 2)); organism.setError(errorsum); } else { errorsum = 999.0; organism.setFitness(0.001); organism.setError(errorsum); } String mask03 = "0.000"; DecimalFormat fmt03 = new DecimalFormat(mask03); if ((out[0] < 0.5) && (out[1] >= 0.5) && (out[2] >= 0.5) && (out[3] < 0.5)) { organism.setWinner(true); return true; } else { organism.setWinner(false); return false; } }