/** * Takes a {@link ProteinSequence} which was created by a * {@link CasePreservingProteinSequenceCreator}. Uses the case info * stored in the user collection to modify the output array. * * <p>Sets elements of the output array which correspond to lowercase letters * to null. * * @param seq Input sequence with case stored as the user collection * @param out */ public static void setLowercaseToNull( ProteinSequence seq, Object[] out) { // should have been set by seq creator Collection<Object> userCollection = seq.getUserCollection(); if(userCollection == null) throw new IllegalArgumentException("Sequence doesn't contain valid case info"); if(userCollection.size() != out.length) throw new IllegalArgumentException("Sequence length doesn't math output array length"); int pos = 0; for(Object isAligned : userCollection) { assert(isAligned instanceof Boolean); if(!(Boolean)isAligned) { out[pos] = null; } pos++; } } }
/** * Takes a {@link ProteinSequence} which was created by a * {@link CasePreservingProteinSequenceCreator}. Uses the case info * stored in the user collection to modify the output array. * * <p>Sets elements of the output array which correspond to lowercase letters * to null. * * @param seq Input sequence with case stored as the user collection * @param out */ public static void setLowercaseToNull( ProteinSequence seq, Object[] out) { // should have been set by seq creator Collection<Object> userCollection = seq.getUserCollection(); if(userCollection == null) throw new IllegalArgumentException("Sequence doesn't contain valid case info"); if(userCollection.size() != out.length) throw new IllegalArgumentException("Sequence length doesn't math output array length"); int pos = 0; for(Object isAligned : userCollection) { assert(isAligned instanceof Boolean); if(!(Boolean)isAligned) { out[pos] = null; } pos++; } } }
/** * Returns an AFPChain corresponding to the alignment between {@code structure1} and {@code structure2}, which is given by the gapped protein sequences {@code sequence1} and {@code sequence2}. The * sequences need not correspond to the entire structures, since local alignment is performed to match the sequences to structures. Assumes that a residue is aligned if and only if it is given by * an uppercase letter. * @param sequence1 <em>Must</em> have {@link ProteinSequence#getUserCollection()} set to document upper- and lower-case as aligned and unaligned; see {@link #getAlignedUserCollection(String)} * @throws StructureException */ public static AFPChain fastaToAfpChain(ProteinSequence sequence1, ProteinSequence sequence2, Structure structure1, Structure structure2) throws StructureException { if (structure1 == null || structure2 == null) { throw new IllegalArgumentException("A structure is null"); } if (sequence1 == null || sequence2 == null) { throw new IllegalArgumentException("A sequence is null"); } Atom[] ca1 = StructureTools.getRepresentativeAtomArray(structure1); Atom[] ca2 = StructureTools.getRepresentativeAtomArray(structure2); ResidueNumber[] residues1 = StructureSequenceMatcher.matchSequenceToStructure(sequence1, structure1); ResidueNumber[] residues2 = StructureSequenceMatcher.matchSequenceToStructure(sequence2, structure2); // nullify ResidueNumbers that have a lowercase sequence character if (sequence1.getUserCollection() != null) { CasePreservingProteinSequenceCreator.setLowercaseToNull(sequence1, residues1); } if (sequence2.getUserCollection() != null) { CasePreservingProteinSequenceCreator.setLowercaseToNull(sequence2, residues2); } return buildAlignment(ca1, ca2, residues1, residues2); }
if (first.getUserCollection() != null) { CasePreservingProteinSequenceCreator.setLowercaseToNull(first, residues); if (second.getUserCollection() != null) { CasePreservingProteinSequenceCreator.setLowercaseToNull(second, nonpermutedResidues);