/** * Provided only for convenience. * * @see #fastaToAfpChain(ProteinSequence, ProteinSequence, Structure, Structure) * @throws StructureException */ public static AFPChain fastaToAfpChain( SequencePair<Sequence<AminoAcidCompound>, AminoAcidCompound> alignment, Structure structure1, Structure structure2) throws StructureException { List<AlignedSequence<Sequence<AminoAcidCompound>, AminoAcidCompound>> seqs = alignment.getAlignedSequences(); StringBuilder sb1 = new StringBuilder(); for (AminoAcidCompound a : seqs.get(0)) { sb1.append(a.getBase()); } try { ProteinSequence seq1 = new ProteinSequence(sb1.toString()); StringBuilder sb2 = new StringBuilder(); for (AminoAcidCompound a : seqs.get(1)) { sb1.append(a.getBase()); } ProteinSequence seq2 = new ProteinSequence(sb2.toString()); LinkedHashMap<String, ProteinSequence> map = new LinkedHashMap<String, ProteinSequence>(); map.put(structure1.getName(), seq1); map.put(structure2.getName(), seq2); return fastaToAfpChain(map, structure1, structure2); } catch (CompoundNotFoundException e) { logger.error( "Unexpected error while creating protein sequences: {}. This is most likely a bug.", e.getMessage()); return null; } }
private void doVariable(Variable v, opendap.dap.AttributeTable parentTable) { List dims = v.getDimensions(); for (int i = 0; i < dims.size(); i++) { Dimension dim = (Dimension) dims.get(i); if (dim.isShared()) usedDims.put(dim.getName(), dim); } // if (v.getAttributes().size() == 0) return; // LOOK DAP 2 say must have empty String name = NcDDS.escapeName(v.getShortName()); opendap.dap.AttributeTable table; if (parentTable == null) { table = new opendap.dap.AttributeTable(name); try { addAttributeTable(name, table); } catch (AttributeExistsException e) { log.error("Cant add " + name, e); } } else { table = parentTable.appendContainer(name); } addAttributes(table, v, v.getAttributes().iterator()); if (v instanceof Structure) { Structure s = (Structure) v; List nested = s.getVariables(); for (int i = 0; i < nested.size(); i++) { Variable nv = (Variable) nested.get(i); doVariable(nv, table); } } }
public Component getTreeCellRendererComponent( JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); if (value instanceof VariableNode) { VariableNode node = (VariableNode) value; tooltipText = node.getToolTipText(); if (node.var instanceof Structure) { Structure s = (Structure) node.var; setIcon(structIcon); tooltipText = s.getNameAndAttributes(); } else tooltipText = node.getToolTipText(); } else if (value instanceof DimensionNode) { DimensionNode node = (DimensionNode) value; tooltipText = node.getToolTipText(); setIcon(dimIcon); } else if (value instanceof GroupNode) { GroupNode node = (GroupNode) value; tooltipText = node.getToolTipText(); } return c; }
/* Structure { int LAT[0]; ... int LAT[149]; } IMAGE_LAT_ARRAY(3600); type = Layout(8); type= 2 (chunked) storageSize = (1,600) dataSize=0 dataAddress=2548046 */ @Test public void testReadOneAtATime() throws java.io.IOException, InvalidRangeException { try (NetcdfFile ncfile = TestH5.openH5("IASI/IASI.h5")) { Variable dset = ncfile.findVariable("U-MARF/EPS/IASI_xxx_1C/DATA/IMAGE_LAT_ARRAY"); assert (null != dset); assert (dset.getDataType() == DataType.STRUCTURE); assert (dset.getRank() == 1); assert (dset.getSize() == 3600); Dimension d = dset.getDimension(0); assert (d.getLength() == 3600); Structure s = (Structure) dset; // read last one - chunked StructureData sd = s.readStructure(3599); assert sd.getScalarInt("LAT[0]") == 70862722; assert sd.getScalarInt("LAT[149]") == 85302263; // read one at a time for (int i = 3590; i < d.getLength(); i++) { s.readStructure(i); System.out.println(" read structure " + i); } } System.out.println("*** testReadIASI ok"); }
/* Structure { int a_name; byte b_name(3); byte c_name(3); short d_name(3); int e_name(3); long f_name(3); int g_name(3); short h_name(3); int i_name(3); long j_name(3); float k_name(3); double l_name(3); } CompoundNative(15); type = Layout(8); type= 1 (contiguous) storageSize = (15,144) dataSize=0 dataAddress=2048 */ @Test public void testReadH5StructureArrayMembers() throws java.io.IOException { try (NetcdfFile ncfile = TestH5.openH5("complex/compound_native.h5")) { Variable dset = ncfile.findVariable("CompoundNative"); assert (null != dset); assert (dset.getDataType() == DataType.STRUCTURE); assert (dset.getRank() == 1); assert (dset.getSize() == 15); Dimension d = dset.getDimension(0); assert (d.getLength() == 15); Structure s = (Structure) dset; // read all with the iterator StructureDataIterator iter = s.getStructureIterator(); while (iter.hasNext()) { StructureData sd = iter.next(); for (StructureMembers.Member m : sd.getMembers()) { Array data = sd.getArray(m); NCdumpW.printArray(data, m.getName(), out, null); } } } System.out.println("*** testReadH5StructureArrayMembers ok"); }
public String toString() { String temp = ""; for (Structure a : this.table) { temp += a.toString() + "\n"; } return temp; }
/** * Link the given next leaf after the given leaf. * * @param <T> The value type of the b+tree objects. * @param <A> The address type used to identify an inner or leaf tier. * @param mutation The mutation state container. * @param leaf The leaf. * @param nextLeaf The next leaf. */ public static <T, A> void link(Mutation<T, A> mutation, Tier<T, A> leaf, Tier<T, A> nextLeaf) { Structure<T, A> structure = mutation.getStructure(); Stage<T, A> writer = structure.getStage(); writer.dirty(mutation.getStash(), leaf); writer.dirty(mutation.getStash(), nextLeaf); nextLeaf.setNext(leaf.getNext()); leaf.setNext(nextLeaf.getAddress()); }
public boolean compareVariables( Variable org, Variable copy, boolean compareData, boolean justOne) { boolean ok = true; if (showCompare) f.format("compare Variable %s to %s %n", org.getFullName(), copy.getFullName()); if (!org.getFullName().equals(copy.getFullName())) { f.format(" ** names are different %s != %s %n", org.getFullName(), copy.getFullName()); ok = false; } // dimensions ok &= checkAll(org.getDimensions(), copy.getDimensions(), null); // attributes ok &= checkAll(org.getAttributes(), copy.getAttributes(), null); // coord sys if ((org instanceof VariableEnhanced) && (copy instanceof VariableEnhanced)) { VariableEnhanced orge = (VariableEnhanced) org; VariableEnhanced copye = (VariableEnhanced) copy; ok &= checkAll(orge.getCoordinateSystems(), copye.getCoordinateSystems(), null); } // data !! if (compareData) { try { compareVariableData(org, copy, showCompare, justOne); } catch (IOException e) { ByteArrayOutputStream bos = new ByteArrayOutputStream(10000); e.printStackTrace(new PrintStream(bos)); f.format("%s", bos.toString()); } } // nested variables if (org instanceof Structure) { if (!(copy instanceof Structure)) { f.format(" ** %s not Structure%n", org); ok = false; } else { Structure orgS = (Structure) org; Structure ncmlS = (Structure) copy; List vars = new ArrayList(); ok &= checkAll(orgS.getVariables(), ncmlS.getVariables(), vars); for (int i = 0; i < vars.size(); i += 2) { Variable orgV = (Variable) vars.get(i); Variable ncmlV = (Variable) vars.get(i + 1); ok &= compareVariables(orgV, ncmlV, false, true); } } } return ok; }
public void testStructureOptionsInference() { Structure s = new OptionsBase.TypeMappedStructure(); assertEquals( "Wrong structure alignment for base structure", Structure.ALIGN_NONE, Native.getStructureAlignment(s.getClass())); assertEquals( "Wrong type mapper for base structure", OptionsBase.TYPE_MAPPER, s.getTypeMapper()); }
/** * Returns an ArrayList of descriptions (as Strings) for this structure, and if it contains * multiples structures, all of those, in order. */ @Override public ArrayList<String> extractDescriptions() { Structure structureData = DisplayDataProcessor.processDisplayStructure(oneToMany.getDisplayData()); ArrayList<String> ret = new ArrayList<String>(); ret.addAll(structureData.extractDescriptions()); return ret; }
/** * *************************************** getAllSimbolInScope * * @param Scope ambit to search * @return a list with structure in the scope ambit *************************************** */ public LinkedList<Structure> getAllStructureInScope(Scope ambit) { LinkedList<Structure> list = new LinkedList<Structure>(); for (Structure a : this.table) { if (a.getScope().getName() == ambit.getName()) { list.add(a); } } return list; }
/** * Get the next leaf in the b-tree from the next property of the given leaf, lock it and add it to * the list of locked leaves in the given leaf level. * * @param <T> The value type of the b+tree objects. * @param <A> The address type used to identify an inner or leaf tier. * @param mutation The mutation state container. * @param leaf The leaf. * @param leafLevel The mutation state for the leaf level. * @return The next leaf or null if the given leaf is the last leaf in the b-tree. */ public static <T, A> Tier<T, A> getNextAndLock( Mutation<T, A> mutation, Tier<T, A> leaf, Level<T, A> leafLevel) { Structure<T, A> structure = mutation.getStructure(); if (!structure.getStorage().isNull(leaf.getNext())) { Tier<T, A> next = structure.getStorage().load(mutation.getStash(), leaf.getNext()); leafLevel.lockAndAdd(next); return next; } return null; }
/** * *************************************** addStructure * * @param string id * @param scope * @param member's list * @return saying if can add *************************************** */ public boolean addStructure(Structure struct) { // TODO revisar si ya existe Structure st = this.getStructure(struct.getId(), struct.getScope()); // significa que no existÃa.. if (st == null) { return table.add(struct); } // si no es null significa que ya existe esa estructura return false; }
/** * Visit each data model element and call its sync method with the root data model element (this). * Do this right after it's been unmarshalled from JSON. */ public void sync() { this.structures_by_name = new HashMap<String, Structure>(); if (this.structures_by_id != null) { for (Structure st : this.structures_by_id.values()) { this.structures_by_name.put(st.getName(), st); st.sync(this); } } if (this.devices != null) { this.devices.sync(this); } }
void makeChildren() { children = new ArrayList<>(); if (var instanceof Structure) { Structure s = (Structure) var; List vars = s.getVariables(); for (int i = 0; i < vars.size(); i++) children.add(new VariableNode(this, (VariableIF) vars.get(i))); } if (debugTree) System.out.println("children=" + var.getShortName() + " "); }
/** * Make a structure for the part * * @param partName partname * @param dimensions dimensions for the structure * @param includeMissing true to include the missing variable * @return a Structure */ protected Structure makeStructure(String partName, List dimensions, boolean includeMissing) { List<GempakParameter> params = gemreader.getParameters(partName); if (params == null) { return null; } Structure sVar = new Structure(ncfile, null, null, partName); sVar.setDimensions(dimensions); for (GempakParameter param : params) { sVar.addMemberVariable(makeParamVariable(param, null)); } if (includeMissing) { sVar.addMemberVariable(makeMissingVariable()); } return sVar; }
/* 60: */ /* 61: */ public void setDataBuffer( DataBuffer paramDataBuffer, int paramInt, boolean paramBoolean) /* 62: */ { /* 63: 91 */ Parameter[] arrayOfParameter = getMembers(); /* 64: 92 */ init(arrayOfParameter); /* 65: 93 */ super.setDataBuffer(paramDataBuffer, paramInt, paramBoolean); /* 66: */ }
public void run() throws XdsInternalException, MetadataValidationException, LoggerException, XdsException { try { s.run(); a.run(); cv.run(); } catch (XdsInternalException e) { rel.add_error( MetadataSupport.XDSRegistryError, e.getMessage(), RegistryUtility.exception_details(e), null); } catch (MetadataException e) { rel.add_error( MetadataSupport.XDSRegistryError, e.getMessage(), RegistryUtility.exception_details(e), null); } pid.run(); for (OMElement ele : m.getRegistryPackages()) validate_internal_classifications(ele); for (OMElement ele : m.getExtrinsicObjects()) validate_internal_classifications(ele); uid.run(); rel.getRegistryErrorList(); // forces output of validation report // System.out.println("Metadata Validator Done"); }
/* 74: */ /* 75: */ public void write(DataBuffer paramDataBuffer, int paramInt, boolean paramBoolean) /* 76: */ throws MemoryAccessViolationException /* 77: */ { /* 78:105 */ Parameter[] arrayOfParameter = getMembers(); /* 79:106 */ init(arrayOfParameter); /* 80:107 */ super.write(paramDataBuffer, paramInt, paramBoolean); /* 81: */ }
private int countSeq(Structure recordStruct) throws IOException { int total = 0; int count = 0; int max = 0; StructureDataIterator iter = recordStruct.getStructureIterator(); try { while (iter.hasNext()) { StructureData sdata = iter.next(); ArraySequence seq1 = sdata.getArraySequence("seq1"); int n = seq1.getStructureDataCount(); total += n; count++; max = Math.max(max, n); } } finally { iter.finish(); } double avg = total / count; int wasted = count * max - total; double wp = (double) wasted / (count * max); System.out.println(" Max = " + max + " avg = " + avg + " wasted = " + wasted + " %= " + wp); return max; }
/* 90: */ /* 91: */ public void push(DataBuffer paramDataBuffer, int paramInt, boolean paramBoolean) /* 92: */ throws MemoryAccessViolationException /* 93: */ { /* 94:119 */ Parameter[] arrayOfParameter = getMembers(); /* 95:120 */ init(arrayOfParameter); /* 96:121 */ super.push(paramDataBuffer, paramInt, paramBoolean); /* 97: */ }
/* 82: */ /* 83: */ public void read(DataBuffer paramDataBuffer, int paramInt, boolean paramBoolean) /* 84: */ throws MemoryAccessViolationException /* 85: */ { /* 86:112 */ Parameter[] arrayOfParameter = getMembers(); /* 87:113 */ init(arrayOfParameter); /* 88:114 */ super.read(paramDataBuffer, paramInt, paramBoolean); /* 89: */ }
@Override protected void buildContentPanel(Orientation style) { super.buildContentPanel(style); displayPanel.addStyleName("SIS_oneToMany_sideBar"); ((VerticalPanel) displayPanel).setSpacing(10); }
/* 98: */ /* 99: */ public void pop(DataBuffer paramDataBuffer, int paramInt, boolean paramBoolean) /* 100: */ throws MemoryAccessViolationException /* 101: */ { /* 102:126 */ Parameter[] arrayOfParameter = getMembers(); /* 103:127 */ init(arrayOfParameter); /* 104:128 */ super.pop(paramDataBuffer, paramInt, paramBoolean); /* 105: */ }
public List<VariableBean> getStructureVariables(Structure s) { List<VariableBean> vlist = new ArrayList<VariableBean>(); for (Variable v : s.getVariables()) { vlist.add(new VariableBean(v)); } return vlist; }
@Test public void testH5StructureDS() throws java.io.IOException { int a_name = 0; String[] b_name = new String[] { "A fight is a contract that takes two people to honor.", "A combative stance means that you've accepted the contract.", "In which case, you deserve what you get.", " -- Professor Cheng Man-ch'ing" }; String c_name = "Hello!"; // H5header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H5header/header")); try (NetcdfDataset ncfile = NetcdfDataset.openDataset(TestH5.testDir + "complex/compound_complex.h5")) { Variable dset = ncfile.findVariable("CompoundComplex"); assert (null != dset); assert (dset.getDataType() == DataType.STRUCTURE); assert (dset.getRank() == 1); assert (dset.getSize() == 6); Dimension d = dset.getDimension(0); assert (d.getLength() == 6); Structure s = (Structure) dset; // read all with the iterator StructureDataIterator iter = s.getStructureIterator(); while (iter.hasNext()) { StructureData sd = iter.next(); assert sd.getScalarInt("a_name") == a_name; a_name++; assert sd.getScalarString("c_name").equals(c_name); String[] results = sd.getJavaArrayString(sd.findMember("b_name")); assert results.length == b_name.length; int count = 0; for (String r : results) assert r.equals(b_name[count++]); for (StructureMembers.Member m : sd.getMembers()) { Array data = sd.getArray(m); NCdumpW.printArray(data, m.getName(), out, null); } } } System.out.println("*** testH5StructureDS ok"); }
/** * Identify a set of modifications in a structure. * * @param structure query {@link Structure}. * @param potentialModifications query {@link ProteinModification}s. */ public void identify( final Structure structure, final Set<ProteinModification> potentialModifications) { if (structure == null) { throw new IllegalArgumentException("Null structure."); } identify(structure.getChains(), potentialModifications); }
/** * Pass in the raw data from an Assessment object, and this will return it in happy, displayable * String form * * @return ArrayList of Strings, having converted the rawData to nicely displayable String data. * Happy days! */ @Override public int getDisplayableData( ArrayList<String> rawData, ArrayList<String> prettyData, int offset) { int num = ((String) rawData.get(offset)).matches("\\d") ? Integer.parseInt((String) rawData.get(offset)) : 0; prettyData.add(offset, num + " selected."); offset++; Structure def = DisplayDataProcessor.processDisplayStructure(oneToMany.getDisplayData()); for (int i = 0; i < num; i++) offset = def.getDisplayableData(rawData, prettyData, offset); return offset; }
@Override public void delete() throws SQLException { if (this.goodie != null) { this.goodie.delete(); } super.delete(); }
public void testFetchObsolete() throws IOException, StructureException { cache.setUseMmCif(false); // TODO Remove after implementing obsolete mmcif fetching cache.setAutoFetch(true); cache.setFetchCurrent(false); cache.setFetchFileEvenIfObsolete(true); Structure s; // OBSOLETE PDB; should throw an exception s = cache.getStructure("1CMW"); assertEquals("Failed to get OBSOLETE file 1CMW.", "1CMW", s.getPDBCode()); s = cache.getStructure("1HHB"); assertEquals("Failed to get OBSOLETE file 1HHB.", "1HHB", s.getPDBCode()); System.err.println( "Please ignore the previous four errors. They are expected for this ancient PDB."); }