private static void processNodeType(OrderedMap<String, Integer> nodeTypeToSize, String subMotif) { String type = subMotif; System.out.println(type); if (type.contains("#")) { type = type.substring(type.indexOf("#") + 1); } type = type.replaceAll(":|\\{|\\}", ""); if (!type.isEmpty()) { if (!nodeTypeToSize.containsKey(type)) { nodeTypeToSize.put(type, 0); } nodeTypeToSize.put(type, nodeTypeToSize.get(type) + 1); } }
/** * Factory method to create an unmodifiable sorted map. * * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ public static <K,V> OrderedMap<K, V> decorate(OrderedMap<K, V> map) { if (map instanceof Unmodifiable) { return map; } return new UnmodifiableOrderedMap<K, V>(map); }
public void testDecorateFactory() { Map map = makeFullMap(); assertSame(map, UnmodifiableOrderedMap.decorate((OrderedMap) map)); try { UnmodifiableOrderedMap.decorate(null); fail(); } catch (IllegalArgumentException ex) { } }
public void testDecorateFactory() { OrderedMapIterator it = makeFullOrderedMapIterator(); assertSame(it, UnmodifiableOrderedMapIterator.decorate(it)); it = ((OrderedMap) getMap()).orderedMapIterator(); assertTrue(it != UnmodifiableOrderedMapIterator.decorate(it)); try { UnmodifiableOrderedMapIterator.decorate(null); fail(); } catch (IllegalArgumentException ex) { } }
private OrderedMap<String, Integer> processTaxonomyString(String taxonomyAsString) { //"protocol(2):in vivo(3):material amplification(5):organism(7)" String[] fragments = taxonomyAsString.split(":"); taxonomyToRender = new ListOrderedMap<String, Integer>(); for (String fragment : fragments) { String classification = fragment.substring(0, fragment.indexOf("(")); taxonomyToRender.put(classification, Integer.valueOf(fragment.replaceAll(classification, "").replaceAll("\\(|\\)", ""))); } return taxonomyToRender; }
public static List<File> flattenISATabFiles(File isatabDirectory, Investigation investigation, Set<String> sampleFilter) { List<File> flattenedFiles = new ArrayList<File>(); if (investigation != null) { System.out.printf("Just imported %s with %d studies.\r", isatabDirectory.getName(), investigation.getStudies().size()); createProtocolLookup(investigation); // for each study, create a merged representation of the information. Meaning, attach the sample information to each // corresponding row in the assay Converter<Object[][], List<String[]>> arrayToListConversion = new ArrayToListConversion(); for (String studyId : investigation.getStudies().keySet()) { Study study = investigation.getStudies().get(studyId); if (study.getStudySample() != null && study.getStudySample().getTableReferenceObject() != null) { List<String[]> studySampleRows = arrayToListConversion.convert(study.getStudySample().getAssayDataMatrix()); for (Assay assay : study.getAssays().values()) { // strange to have to do this, but apparently I must. Otherwise assay.getAssayDataMatrix() fails with a null pointer. if (assay.getTableReferenceObject() != null) { OrderedMap<Integer, List<String>> merged = new ListOrderedMap<Integer, List<String>>(); Object[][] assayDataMatrix = assay.getAssayDataMatrix(); List<String[]> assayRows = arrayToListConversion.convert(assayDataMatrix); performMergeAssayWithStudySample(merged, studySampleRows, assayRows, sampleFilter); // now do output of file File flattenedStudyFileName = constructFlattenedFileName(isatabDirectory, studyId + ":" + assay.getAssayReference()); printMergedInformationToFile(flattenedStudyFileName, merged); flattenedFiles.add(flattenedStudyFileName); } } } } } return flattenedFiles; }
/** * Returns two OrderedMaps composed of Strings to Integers describing the structure of a motif in terms of it's * topological features (in order) and node types with frequencies. * * @param representation - The motif representation * @return Returns two OrderedMaps composed of Strings to Integers */ public static Pair<OrderedMap<String, Integer>, OrderedMap<String, Integer>> getMotifStructure(String representation) { // e.g. Linear:Sample Name -> 1 or Branch:Protocol REF -> 4 OrderedMap<String, Integer> topologyToSize = new ListOrderedMap<String, Integer>(); OrderedMap<String, Integer> nodeTypeToSize = new ListOrderedMap<String, Integer>(); List<String> subMotifsInMotif = MotifProcessingUtils.getNodesInBranch(representation); for (String subMotif : subMotifsInMotif) { processNodeType(nodeTypeToSize, subMotif); } return new Pair<OrderedMap<String, Integer>, OrderedMap<String, Integer>>(topologyToSize, nodeTypeToSize); }
public MapIterator makeEmptyMapIterator() { resetEmpty(); return ((OrderedMap) AbstractTestOrderedMap.this.map).orderedMapIterator(); }
public MapIterator makeFullMapIterator() { resetFull(); return ((OrderedMap) AbstractTestOrderedMap.this.map).orderedMapIterator(); }
public Map makeFullMap() { OrderedMap m = ListOrderedMap.decorate(new HashMap()); addSampleMappings(m); return UnmodifiableOrderedMap.decorate(m); }
public MapIterator makeFullMapIterator() { return UnmodifiableOrderedMapIterator.decorate(((OrderedMap) getMap()).orderedMapIterator()); }
public void setTaxonomyItems(OrderedMap<String, TaxonomyItem> taxonomyItems) { this.taxonomyItems = taxonomyItems; }
/** * Return a mapping of batch ids to a list of QueryTrace elements * @return */ public OrderedMap<Integer, List<QueryTrace>> getBatches() { return (this.query_batches); }
/** * Constructor that wraps (not copies). * * @param map the map to decorate, must not be null * @throws IllegalArgumentException if the collection is null */ public AbstractOrderedMapDecorator(OrderedMap<K, V> map) { super(map); }
/** * Gets the map being decorated. * * @return the decorated map */ protected OrderedMap<K, V> getOrderedMap() { return (OrderedMap<K, V>) map; }
/** * Factory method to create an ordered map. * <p/> * An <code>ArrayList</code> is used to retain order. * * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ public static <K,V> OrderedMap<K, V> decorate(Map<K, V> map) { return new ListOrderedMap<K, V>(map); }
/** * Constructor that wraps (not copies). * * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ private UnmodifiableOrderedMap(OrderedMap<K, V> map) { super(map); }