public Collection<GMTEntry> convert(final Model model)
	{
		final Collection<GMTEntry> toReturn = new TreeSet<GMTEntry>(new Comparator<GMTEntry>() {
			@Override
			public int compare(GMTEntry o1, GMTEntry o2) {
				return o1.toString().compareTo(o2.toString());
			}
		});

		Model l3Model;
		// convert to level 3 in necessary
		if (model.getLevel() == BioPAXLevel.L2)
			l3Model = (new LevelUpgrader()).filter(model);
		else
			l3Model = model;

		//a modifiable copy of the set of all PRs in the model -
		//after all, it has all the ERs that do not belong to any pathway
		final Set<EntityReference> entityReferences =
				new HashSet<EntityReference>(l3Model.getObjects(EntityReference.class));

		final Set<Pathway> pathways = l3Model.getObjects(Pathway.class);
		for (Pathway pathway : pathways)
		{
			String name = (pathway.getDisplayName() == null) ? pathway.getStandardName() : pathway.getDisplayName();
			if(name == null || name.isEmpty())
				name = pathway.getUri();

			final Pathway currentPathway = pathway;
			final String currentPathwayName = name;

			LOG.debug("Begin converting " + currentPathwayName + " pathway, uri=" + currentPathway.getUri());
			final Set<EntityReference> ers = new HashSet<EntityReference>();
			final Traverser traverser = new AbstractTraverser(SimpleEditorMap.L3,
					Fetcher.nextStepFilter, Fetcher.objectPropertiesOnlyFilter) {
				@Override
				protected void visit(Object range, BioPAXElement domain, Model model, PropertyEditor editor)
				{
					BioPAXElement bpe = (BioPAXElement) range; //cast is safe (due to objectPropertiesOnlyFilter)
					if(bpe instanceof EntityReference) {
						ers.add((EntityReference) bpe);
					}
					if(bpe instanceof Pathway) {
						if(skipSubPathways)
						{	//do not traverse into the sub-pathway; log
							LOG.debug("Skipping sub-pathway: " + bpe.getUri());
						} else {
							traverse(bpe, model);
						}
					} else {
						traverse(bpe, model);
					}
				}
			};
			//run it - collect all PRs from the pathway
			traverser.traverse(currentPathway, null);

			if(!ers.isEmpty()) {
				LOG.debug("For pathway: " + currentPathwayName + " (" + currentPathway.getUri()
						+ "), got " + ers.size() + " ERs");
				// create GMT entries
				Collection<GMTEntry> entries = createGseaEntries(currentPathway.getUri(),
						currentPathwayName, getDataSource(currentPathway.getDataSource()), ers);
				if(!entries.isEmpty())
					toReturn.addAll(entries);
				entityReferences.removeAll(ers);//keep not processed PRs (a PR can be processed multiple times)
				LOG.debug("- collected " + entries.size() + "entries.");
			}
		}

		//when there're no pathways, only empty pathays, pathways w/o PRs, then use all/rest of PRs -
		//organize PRs by species (GSEA s/w can handle only same species identifiers in a data row)
		if(!entityReferences.isEmpty() && !skipOutsidePathways) {
			LOG.info("Creating entries for the rest of PRs (outside any pathway)...");
			toReturn.addAll(createGseaEntries("other","other", getDataSource(l3Model.getObjects(Provenance.class)),entityReferences));
		}

		return toReturn;
	}
public Collection < GMTEntry > convert ( final Model model ) { final Collection < GMTEntry > toReturn = new TreeSet < GMTEntry > ( new Comparator < GMTEntry > ( ) { @ Override public int compare ( GMTEntry o1 , GMTEntry o2 ) { return o1 . toString ( ) . compareTo ( o2 . toString ( ) ) ; } } ) ; Model l3Model ; if ( model . getLevel ( ) == BioPAXLevel . L2 ) l3Model = ( new LevelUpgrader ( ) ) . filter ( model ) ; else l3Model = model ; final Set < EntityReference > entityReferences = new HashSet < EntityReference > ( l3Model . getObjects ( EntityReference . class ) ) ; final Set < Pathway > pathways = l3Model . getObjects ( Pathway . class ) ; for ( Pathway pathway : pathways ) { String name = ( pathway . getDisplayName ( ) == null ) ? pathway . getStandardName ( ) : pathway . getDisplayName ( ) ; if ( name == null || name . isEmpty ( ) ) name = pathway . getUri ( ) ; final Pathway currentPathway = pathway ; final String currentPathwayName = name ; LOG . debug ( "Begin converting " + currentPathwayName + " pathway, uri=" + currentPathway . getUri ( ) ) ; final Set < EntityReference > ers = new HashSet < EntityReference > ( ) ; final Traverser traverser = new AbstractTraverser ( SimpleEditorMap . L3 , Fetcher . nextStepFilter , Fetcher . objectPropertiesOnlyFilter ) { @ Override protected void visit ( Object range , BioPAXElement domain , Model model , PropertyEditor editor ) { BioPAXElement bpe = ( BioPAXElement ) range ; if ( bpe instanceof EntityReference ) { ers . add ( ( EntityReference ) bpe ) ; } if ( bpe instanceof Pathway ) { if ( skipSubPathways ) { LOG . debug ( "Skipping sub-pathway: " + bpe . getUri ( ) ) ; } else { traverse ( bpe , model ) ; } } else { traverse ( bpe , model ) ; } } } ; traverser . traverse ( currentPathway , null ) ; if ( ! ers . isEmpty ( ) ) { LOG . debug ( "For pathway: " + currentPathwayName + " (" + currentPathway . getUri ( ) + "), got " + ers . size ( ) + " ERs" ) ; Collection < GMTEntry > entries = createGseaEntries ( currentPathway . getUri ( ) , currentPathwayName , getDataSource ( currentPathway . getDataSource ( ) ) , ers ) ; if ( ! entries . isEmpty ( ) ) toReturn . addAll ( entries ) ; entityReferences . removeAll ( ers ) ; LOG . debug ( "- collected " + entries . size ( ) + "entries." ) ; } } if ( ! entityReferences . isEmpty ( ) && ! skipOutsidePathways ) { LOG . info ( "Creating entries for the rest of PRs (outside any pathway)..." ) ; toReturn . addAll ( createGseaEntries ( "other" , "other" , getDataSource ( l3Model . getObjects ( Provenance . class ) ) , entityReferences ) ) ; } return toReturn ; }
Creates GMT entries from the pathways contained in the model.
@param model Model
@return a set of GMT entries