From: amwaterhouse Date: Tue, 5 Dec 2006 17:55:26 +0000 (+0000) Subject: Sequence is char [] X-Git-Tag: Release_2_3~520 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4d2e0d36506302cc00677527725bcccbdf27d766;p=jalview.git Sequence is char [] --- diff --git a/src/jalview/commands/ChangeCaseCommand.java b/src/jalview/commands/ChangeCaseCommand.java index 49faa50..00d9000 100644 --- a/src/jalview/commands/ChangeCaseCommand.java +++ b/src/jalview/commands/ChangeCaseCommand.java @@ -71,7 +71,7 @@ public class ChangeCaseCommand implements CommandI start = regions[r][0]; for (int s = 0; s < seqs.length; s++) { - sequence = seqs[s].getSequence(); + sequence = seqs[s].getSequenceAsString(); StringBuffer newSeq = new StringBuffer(); if (regions[r][1] > sequence.length()) diff --git a/src/jalview/commands/EditCommand.java b/src/jalview/commands/EditCommand.java index 72d82aa..be11d44 100644 --- a/src/jalview/commands/EditCommand.java +++ b/src/jalview/commands/EditCommand.java @@ -207,7 +207,7 @@ public class EditCommand implements CommandI if(command.seqs[i].getLength()>command.position) { command.string[i] = command.seqs[i].getSequence(command.position, - command.position + command.number).toCharArray(); + command.position + command.number); command.seqs[i].deleteChars(command.position, command.position + command.number); @@ -235,7 +235,8 @@ public class EditCommand implements CommandI else command.al.addSequence(command.seqs[i]); } - tmp = new StringBuffer(command.seqs[i].getSequence()); + tmp = new StringBuffer(); + tmp.append(command.seqs[i].getSequence()); if(command.string!=null && command.string[i]!=null) { diff --git a/src/jalview/commands/RemoveGapsCommand.java b/src/jalview/commands/RemoveGapsCommand.java index ddd6b76..ba39381 100644 --- a/src/jalview/commands/RemoveGapsCommand.java +++ b/src/jalview/commands/RemoveGapsCommand.java @@ -60,7 +60,7 @@ public class RemoveGapsCommand extends EditCommand deletedCols = 0; startCol = -1; endCol = -1; - sequence = seqs[s].getSequence(start, end+1).toCharArray(); + sequence = seqs[s].getSequence(start, end+1); jSize = sequence.length; for (j=0; j= oseq.getStart()) { @@ -303,7 +303,7 @@ public class AlignmentView } else { - alignment[s].setSequence(alignment[s].getSequence() + + alignment[s].setSequence(alignment[s].getSequenceAsString() + hseq.getSequence()); if (hseq.getEnd() >= hseq.getStart()) { @@ -332,7 +332,7 @@ public class AlignmentView } else { - alignment[s].setSequence(alignment[s].getSequence() + + alignment[s].setSequence(alignment[s].getSequenceAsString() + mseq[s].getSequence()); if (mseq[s].getEnd() >= mseq[s].getStart()) { @@ -366,7 +366,7 @@ public class AlignmentView } else { - alignment[s].setSequence(alignment[s].getSequence() + + alignment[s].setSequence(alignment[s].getSequenceAsString() + oseq.getSequence()); if (oseq.getEnd() >= oseq.getStart()) { @@ -397,7 +397,7 @@ public class AlignmentView } /** * returns simple array of start end positions of visible range on alignment. - * vis_start and vis_end are inclusive - use SequenceI.getSubSequence(vis_start, vis_end+1) to recover visible sequence from underlying alignment. + * vis_start and vis_end are inclusive - use SequenceI.getSubSequence(vis_start, vis_end+1) to recover visible sequence from underlying alignment. * @return int[] { start_i, end_i } for 1= sequence.length()) + if (start >= sequence.length) { - return ""; + System.out.println("DOES THIS GET CALLED???"); } - if (end >= sequence.length()) + if (end >= sequence.length) { - end = sequence.length(); + end = sequence.length; } - return this.sequence.substring(start, end); + char [] reply = new char[end-start]; + System.arraycopy(sequence, start, reply, 0, end-start); + + return reply; } + /** * make a new Sequence object from start to end (including gaps) over this seqeunce * @param start int @@ -386,8 +402,8 @@ public class Sequence implements SequenceI { if (start < 0) start = 0; - String seq = getSequence(start, end); - if (seq == "") + char [] seq = getSequence(start, end); + if (seq.length == 0) return null; int nstart = findPosition(start); int nend = findPosition(end) - 1; @@ -407,9 +423,9 @@ public class Sequence implements SequenceI */ public char getCharAt(int i) { - if (i < sequence.length()) + if (i < sequence.length) { - return sequence.charAt(i); + return sequence[i]; } else { @@ -450,9 +466,9 @@ public class Sequence implements SequenceI int j = start; int i = 0; - while ( (i < sequence.length()) && (j <= end) && (j <= pos)) + while ( (i < sequence.length) && (j <= end) && (j <= pos)) { - if (!jalview.util.Comparison.isGap(sequence.charAt(i))) + if (!jalview.util.Comparison.isGap(sequence[i])) { j++; } @@ -481,10 +497,10 @@ public class Sequence implements SequenceI { int j = 0; int pos = start; - int seqlen = sequence.length(); + int seqlen = sequence.length; while ( (j < i) && (j < seqlen)) { - if (!jalview.util.Comparison.isGap( (sequence.charAt(j)))) + if (!jalview.util.Comparison.isGap( sequence[j] )) { pos++; } @@ -503,14 +519,14 @@ public class Sequence implements SequenceI public int[] gapMap() { String seq = jalview.analysis.AlignSeq.extractGaps(jalview.util.Comparison. - GapChars, sequence); + GapChars, new String(sequence)); int[] map = new int[seq.length()]; int j = 0; int p = 0; - while (j < sequence.length()) + while (j < sequence.length) { - if (!jalview.util.Comparison.isGap(sequence.charAt(j))) + if (!jalview.util.Comparison.isGap(sequence[j])) { map[p++] = j; } @@ -525,38 +541,30 @@ public class Sequence implements SequenceI * DOCUMENT ME! * * @param i DOCUMENT ME! - */ - public void deleteCharAt(int i) - { - if (i >= sequence.length()) - { - return; - } - - sequence = sequence.substring(0, i) + sequence.substring(i + 1); - } - - /** - * DOCUMENT ME! - * - * @param i DOCUMENT ME! * @param j DOCUMENT ME! */ public void deleteChars(int i, int j) { - if (i >= sequence.length()) + if (i >= sequence.length) { return; } - if (j >= sequence.length()) + char [] tmp; + + if (j >= sequence.length) { - sequence = sequence.substring(0, i); + tmp = new char[i]; + System.arraycopy(sequence,0,tmp,0,i); } else { - sequence = sequence.substring(0, i) + sequence.substring(j); + tmp = new char[sequence.length-j+i]; + System.arraycopy(sequence,0,tmp,0,i); + System.arraycopy(sequence,j,tmp,i,sequence.length-j); } + + sequence = tmp; } /** @@ -568,27 +576,32 @@ public class Sequence implements SequenceI */ public void insertCharAt(int i, int length, char c) { - StringBuffer tmp; + char [] tmp = new char[sequence.length+length]; - if (i >= sequence.length()) + if (i >= sequence.length) { - tmp = new StringBuffer(sequence); + System.arraycopy(sequence, 0, tmp, 0, sequence.length); + i = sequence.length; } else - tmp = new StringBuffer(sequence.substring(0, i)); + { + System.arraycopy(sequence, 0, tmp, 0, i); + } + + int index = i; while (length > 0) { - tmp.append(c); + tmp[ index++ ] = c; length--; } - if (i < sequence.length()) + if (i < sequence.length) { - tmp.append(sequence.substring(i)); + System.arraycopy(sequence, i, tmp, index, sequence.length-i ); } - sequence = tmp.toString(); + sequence = tmp; } public void insertCharAt(int i, char c) diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index a8327cf..bb5e799 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -20,8 +20,6 @@ package jalview.datamodel; import java.util.*; -import java.awt.*; - /** * DOCUMENT ME! @@ -100,7 +98,7 @@ public interface SequenceI * * @return DOCUMENT ME! */ - public String getSequence(); + public String getSequenceAsString(); /** * DOCUMENT ME! @@ -110,7 +108,24 @@ public interface SequenceI * * @return DOCUMENT ME! */ - public String getSequence(int start, int end); + public String getSequenceAsString(int start, int end); + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public char [] getSequence(); + + /** + * DOCUMENT ME! + * + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public char [] getSequence(int start, int end); /** * create a new sequence object from start to end of this sequence * @param start int @@ -174,12 +189,6 @@ public interface SequenceI */ public void deleteChars(int i, int j); - /** - * DOCUMENT ME! - * - * @param i DOCUMENT ME! - */ - public void deleteCharAt(int i); /** * DOCUMENT ME! diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index fb2047e..05ba166 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -317,7 +317,7 @@ public class AlignViewport cons.findQuality(); } - String sequence = cons.getConsSequence().getSequence(); + char [] sequence = cons.getConsSequence().getSequence(); float minR; float minG; float minB; @@ -352,7 +352,7 @@ public class AlignViewport { float value = 0; - c = sequence.charAt(i); + c = sequence[i]; if (Character.isDigit(c)) value = (int) (c - '0'); @@ -1513,7 +1513,7 @@ public class AlignViewport } else { for(i=0; i" + printId(s[i]) +"\n"); - if (s[i].getSequence().length() > max) + if (s[i].getSequence().length > max) { - max = s[i].getSequence().length(); + max = s[i].getSequence().length; } i++; @@ -204,9 +204,9 @@ public class BLCFile extends AlignFile while ((i < s.length) && (s[i] != null)) { - if (s[i].getSequence().length() > j) + if (s[i].getSequence().length > j) { - out.append(s[i].getSequence().substring(j, j + 1)); + out.append(s[i].getSequenceAsString(j, j + 1)); } else { diff --git a/src/jalview/io/ClustalFile.java b/src/jalview/io/ClustalFile.java index e3f83ee..b43e3ea 100755 --- a/src/jalview/io/ClustalFile.java +++ b/src/jalview/io/ClustalFile.java @@ -164,9 +164,9 @@ public class ClustalFile { String tmp = printId(s[i]); - if (s[i].getSequence().length() > max) + if (s[i].getSequence().length > max) { - max = s[i].getSequence().length(); + max = s[i].getSequence().length; } if (tmp.length() > maxid) @@ -198,16 +198,16 @@ public class ClustalFile int start = i * len; int end = start + len; - if ( (end < s[j].getSequence().length()) && - (start < s[j].getSequence().length())) + if ( (end < s[j].getSequence().length) && + (start < s[j].getSequence().length)) { - out.append(s[j].getSequence().substring(start, end)); + out.append(s[j].getSequenceAsString(start, end)); } else { - if (start < s[j].getSequence().length()) + if (start < s[j].getSequence().length) { - out.append(s[j].getSequence().substring(start)); + out.append(s[j].getSequenceAsString().substring(start)); } } diff --git a/src/jalview/io/DBRefFetcher.java b/src/jalview/io/DBRefFetcher.java index 4a6044f..bd3c733 100644 --- a/src/jalview/io/DBRefFetcher.java +++ b/src/jalview/io/DBRefFetcher.java @@ -305,7 +305,8 @@ public class DBRefFetcher implements Runnable System.out.println("Adding dbref to " + sequence.getName() + " : " + entry.getAccession().elementAt(0).toString()); - String nonGapped = AlignSeq.extractGaps("-. ", sequence.getSequence()). + String nonGapped = AlignSeq.extractGaps("-. ", + sequence.getSequenceAsString()). toUpperCase(); int absStart = entry.getUniprotSequence().getContent().indexOf( diff --git a/src/jalview/io/FastaFile.java b/src/jalview/io/FastaFile.java index 6e3ced8..f257c6c 100755 --- a/src/jalview/io/FastaFile.java +++ b/src/jalview/io/FastaFile.java @@ -73,7 +73,7 @@ public class FastaFile extends AlignFile { if (count != 0) { - if (!isValidProteinSequence(sb.toString())) + if (!isValidProteinSequence(sb.toString().toCharArray())) { throw new IOException(AppletFormatAdapter.INVALID_CHARACTERS +" : "+seq.getName() @@ -98,7 +98,7 @@ public class FastaFile extends AlignFile if (count > 0) { - if (!isValidProteinSequence(sb.toString())) + if (!isValidProteinSequence(sb.toString().toCharArray())) { throw new IOException(AppletFormatAdapter.INVALID_CHARACTERS +" : "+seq.getName() @@ -144,11 +144,11 @@ public class FastaFile extends AlignFile if (end < s[i].getLength()) { - out.append(s[i].getSequence(start, end) + "\n"); + out.append(s[i].getSequenceAsString(start, end) + "\n"); } else if (start < s[i].getLength()) { - out.append(s[i].getSequence(start, s[i].getLength()) + "\n"); + out.append(s[i].getSequenceAsString(start, s[i].getLength()) + "\n"); } } diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 42b032d..e4fd38e 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -125,7 +125,7 @@ public class FeaturesFile extends AlignFile else { UserColourScheme ucs = new UserColourScheme(st.nextToken()); - colours.put(type, ucs.findColour("A")); + colours.put(type, ucs.findColour('A')); if (st.hasMoreElements()) { String link = st.nextToken(); @@ -230,7 +230,7 @@ public class FeaturesFile extends AlignFile { // Probably the old style groups file UserColourScheme ucs = new UserColourScheme(type); - colours.put(type, ucs.findColour("A")); + colours.put(type, ucs.findColour('A')); } sf = new SequenceFeature(type, desc, "", start, end, featureGroup); diff --git a/src/jalview/io/JnetAnnotationMaker.java b/src/jalview/io/JnetAnnotationMaker.java index 577e874..07a0068 100755 --- a/src/jalview/io/JnetAnnotationMaker.java +++ b/src/jalview/io/JnetAnnotationMaker.java @@ -42,9 +42,9 @@ public class JnetAnnotationMaker // in the future we could search for the query // sequence in the alignment before calling this function. SequenceI seqRef = al.getSequenceAt(firstSeq); - int width = preds[0].getSequence().length(); + int width = preds[0].getSequence().length; int[] gapmap = al.getSequenceAt(firstSeq).gapMap(); - if ((delMap!=null && delMap.length > width) || (delMap==null && gapmap.length!=width)) + if ((delMap!=null && delMap.length > width) || (delMap==null && gapmap.length!=width)) { throw (new Exception( "Number of residues in "+(delMap==null ? "" : " mapped ")+"supposed query sequence ('" + @@ -127,7 +127,7 @@ public class JnetAnnotationMaker for (int j = 0; j < width; j++) { annotations[gapmap[delMap[j]]] = new Annotation(preds[i].getCharAt( - j) + "", "", ' ', 0); + j) + "", "", ' ', 0); } } } @@ -178,4 +178,4 @@ public class JnetAnnotationMaker */ } -} \ No newline at end of file +} diff --git a/src/jalview/io/MSFfile.java b/src/jalview/io/MSFfile.java index c06757b..61b3528 100755 --- a/src/jalview/io/MSFfile.java +++ b/src/jalview/io/MSFfile.java @@ -145,7 +145,7 @@ public class MSFfile extends AlignFile // Replace ~ with a sensible gap character seq = seq.replace('~', '-'); - if (!isValidProteinSequence(seq)) + if (!isValidProteinSequence(seq.toCharArray())) { throw new IOException(AppletFormatAdapter. INVALID_CHARACTERS @@ -227,9 +227,11 @@ public class MSFfile extends AlignFile while ((i < seqs.length) && (seqs[i] != null)) { // Replace all internal gaps with . and external spaces with ~ - s[i] =new Sequence(seqs[i].getName(),seqs[i].getSequence().replace('-', '.')); + s[i] =new Sequence(seqs[i].getName(),seqs[i].getSequenceAsString().replace('-', '.')); + + StringBuffer sb = new StringBuffer(); + sb.append(s[i].getSequence()); - StringBuffer sb = new StringBuffer(s[i].getSequence()); for (int ii = 0; ii < sb.length(); ii++) { if (sb.charAt(ii) == '.') @@ -252,9 +254,9 @@ public class MSFfile extends AlignFile s[i].setSequence(sb.toString()); - if (s[i].getSequence().length() > max) + if (s[i].getSequence().length > max) { - max = s[i].getSequence().length(); + max = s[i].getSequence().length; } i++; @@ -270,13 +272,13 @@ public class MSFfile extends AlignFile int [] checksums = new int[s.length]; while ( i < s.length ) { - checksums[i] = checkSum(s[i].getSequence()); + checksums[i] = checkSum(s[i].getSequenceAsString()); bigChecksum += checksums[i]; i++; } long maxNB = 0; - out.append(" MSF: " + s[0].getSequence().length() + " Type: " + + out.append(" MSF: " + s[0].getSequence().length + " Type: " + (is_NA ? "N" : "P") + " Check: " + (bigChecksum%10000) + " ..\n\n\n"); String[] nameBlock = new String[s.length]; @@ -289,7 +291,7 @@ public class MSFfile extends AlignFile nameBlock[i] = new String(" Name: " + printId(s[i])+" "); idBlock[i] = new String("Len: " + - maxLenpad.form(s[i].getSequence().length()) + " Check: " + + maxLenpad.form(s[i].getSequence().length) + " Check: " + maxChkpad.form(checksums[i]) + " Weight: 1.00\n"); if (s[i].getName().length() > maxid) @@ -350,10 +352,10 @@ public class MSFfile extends AlignFile int start = (i * 50) + (k * 10); int end = start + 10; - if ((end < s[j].getSequence().length()) && - (start < s[j].getSequence().length())) + if ((end < s[j].getSequence().length) && + (start < s[j].getSequence().length)) { - out.append(s[j].getSequence().substring(start, end)); + out.append(s[j].getSequence(start, end)); if (k < 4) { @@ -366,9 +368,9 @@ public class MSFfile extends AlignFile } else { - if (start < s[j].getSequence().length()) + if (start < s[j].getSequence().length) { - out.append(s[j].getSequence().substring(start)); + out.append(s[j].getSequenceAsString().substring(start)); out.append("\n"); } else diff --git a/src/jalview/io/PIRFile.java b/src/jalview/io/PIRFile.java index fa9a28b..8b05171 100755 --- a/src/jalview/io/PIRFile.java +++ b/src/jalview/io/PIRFile.java @@ -114,7 +114,7 @@ public class PIRFile while ( (i < s.length) && (s[i] != null)) { - String seq = s[i].getSequence(); + String seq = s[i].getSequenceAsString(); seq = seq + "*"; diff --git a/src/jalview/io/PfamFile.java b/src/jalview/io/PfamFile.java index bbd441c..7cb381d 100755 --- a/src/jalview/io/PfamFile.java +++ b/src/jalview/io/PfamFile.java @@ -138,9 +138,9 @@ public class PfamFile { String tmp = printId(s[i]); - if (s[i].getSequence().length() > max) + if (s[i].getSequence().length > max) { - max = s[i].getSequence().length(); + max = s[i].getSequence().length; } if (tmp.length() > maxid) @@ -162,7 +162,7 @@ public class PfamFile { out.append(new Format("%-" + maxid + "s").form( printId(s[j])+" ")); - out.append(s[j].getSequence() + "\n"); + out.append(s[j].getSequenceAsString() + "\n"); j++; } diff --git a/src/jalview/io/PileUpfile.java b/src/jalview/io/PileUpfile.java index fa77802..be16169 100755 --- a/src/jalview/io/PileUpfile.java +++ b/src/jalview/io/PileUpfile.java @@ -80,21 +80,21 @@ public class PileUpfile extends MSFfile int[] checksums = new int[s.length]; while (i < s.length) { - checksums[i] = checkSum(s[i].getSequence()); + checksums[i] = checkSum(s[i].getSequenceAsString()); bigChecksum += checksums[i]; i++; } - out.append(" MSF: " + s[0].getSequence().length() + + out.append(" MSF: " + s[0].getSequence().length + " Type: P Check: " + bigChecksum%10000 + " ..\n\n\n"); i=0; while ( (i < s.length) && (s[i] != null)) { - String seq = s[i].getSequence(); + String seq = s[i].getSequenceAsString(); out.append(" Name: " + printId(s[i]) + " oo Len: " + - s[i].getSequence().length() + " Check: " + checksums[i] + + seq.length() + " Check: " + checksums[i] + " Weight: 1.00\n"); if (seq.length() > max) @@ -142,10 +142,10 @@ public class PileUpfile extends MSFfile int start = (i * 50) + (k * 10); int end = start + 10; - if ( (end < s[j].getSequence().length()) && - (start < s[j].getSequence().length())) + if ( (end < s[j].getSequence().length) && + (start < s[j].getSequence().length)) { - out.append(s[j].getSequence().substring(start, end)); + out.append(s[j].getSequence(start, end)); if (k < 4) { @@ -158,9 +158,9 @@ public class PileUpfile extends MSFfile } else { - if (start < s[j].getSequence().length()) + if (start < s[j].getSequence().length) { - out.append(s[j].getSequence().substring(start)); + out.append(s[j].getSequenceAsString().substring(start)); out.append("\n"); } else diff --git a/src/jalview/io/VamsasDatastore.java b/src/jalview/io/VamsasDatastore.java index 395a251..2f43f03 100755 --- a/src/jalview/io/VamsasDatastore.java +++ b/src/jalview/io/VamsasDatastore.java @@ -45,11 +45,11 @@ import org.exolab.castor.xml.*; import org.exolab.castor.mapping.Mapping; /* - * + * * static { * org.exolab.castor.util.LocalConfiguration.getInstance().getProperties().setProperty( * "org.exolab.castor.serializer", "org.apache.xml.serialize.XMLSerilazizer"); } - * + * */ public class VamsasDatastore { @@ -84,11 +84,11 @@ public class VamsasDatastore { * (UniprotFile) unmar.unmarshal(new FileReader(file)); // 3. marshal the data * with the total price back and print the XML in the console Marshaller * marshaller = new Marshaller( new FileWriter(file) ); - * + * * marshaller.setMapping(map); marshaller.marshal(af); } catch (Exception e) { * e.printStackTrace(); } } - * - * + * + * */ /** * @return the Vobject bound to Jalview datamodel object @@ -100,7 +100,7 @@ public class VamsasDatastore { } /** - * + * * @param vobj * @return Jalview datamodel object bound to the vamsas document object */ @@ -126,11 +126,11 @@ public class VamsasDatastore { if (id==null || vobj.getVorbaId()==null) Cache.log.error("Failed to get id for "+(vobj.isRegisterable() ? "registerable" : "unregisterable") +" object "+vobj); } - + if (vobj2jv.containsKey(vobj.getVorbaId()) && !((VorbaId)vobj2jv.get(vobj.getVorbaId())).equals(jvobj)) { Cache.log.debug("Warning? Overwriting existing vamsas id binding for "+vobj.getVorbaId(), new Exception("Overwriting vamsas id binding.")); } - else if (jv2vobj.containsKey(jvobj) && !((VorbaId)jv2vobj.get(jvobj)).equals(vobj.getVorbaId())) + else if (jv2vobj.containsKey(jvobj) && !((VorbaId)jv2vobj.get(jvobj)).equals(vobj.getVorbaId())) { Cache.log.debug("Warning? Overwriting existing jalview object binding for "+jvobj, new Exception("Overwriting jalview object binding.")); } @@ -139,12 +139,12 @@ public class VamsasDatastore { // we just update the hash's regardless! vobj2jv.put(vobj.getVorbaId(), jvobj); // JBPNote - better implementing a hybrid invertible hash. - jv2vobj.put(jvobj, vobj.getVorbaId()); + jv2vobj.put(jvobj, vobj.getVorbaId()); } /** * put the alignment viewed by AlignViewport into cdoc. - * + * * @param av alignViewport to be stored * @param aFtitle title for alignment */ @@ -197,7 +197,7 @@ public class VamsasDatastore { sequence = new Sequence(); bindjvvobj(sq, sequence); sq.setVamsasId(sequence.getVorbaId().getId()); - sequence.setSequence(sq.getSequence()); + sequence.setSequence(sq.getSequenceAsString()); sequence.setDictionary(dict); sequence.setName(jal.getDataset().getSequenceAt(i).getName()); sequence.setStart(jal.getDataset().getSequenceAt(i).getStart()); @@ -282,7 +282,7 @@ public class VamsasDatastore { // //////////////////////////////////////////// // Save the Alignments - Alignment alignment = (Alignment) getjv2vObj(av); // this is so we can get the alignviewport back + Alignment alignment = (Alignment) getjv2vObj(av); // this is so we can get the alignviewport back if (alignment == null) { alignment = new Alignment(); @@ -306,7 +306,7 @@ public class VamsasDatastore { { alseq = new AlignmentSequence(); // TODO: VAMSAS: translate lowercase symbols to annotation ? - alseq.setSequence(jal.getSequenceAt(i).getSequence()); + alseq.setSequence(jal.getSequenceAt(i).getSequenceAsString()); alseq.setName(jal.getSequenceAt(i).getName()); alseq.setStart(jal.getSequenceAt(i).getStart()); alseq.setEnd(jal.getSequenceAt(i).getEnd()); @@ -555,7 +555,7 @@ public class VamsasDatastore { an.addProperty(newProperty("jalview:graphType",null, ((aa[i].graph==jalview.datamodel.AlignmentAnnotation.BAR_GRAPH) ? "BAR_GRAPH" : "LINE_GRAPH"))); - /** and on and on.. + /** and on and on.. vProperty=new Property(); vProperty.setName("jalview:graphThreshhold"); vProperty.setContent(aa[i].threshold); @@ -653,7 +653,7 @@ public class VamsasDatastore { /** * correctly create a RangeAnnotation from a jalview sequence feature - * + * * @param dsa * (typically DataSetAnnotations or AlignmentSequenceAnnotation) * @param feature @@ -695,7 +695,7 @@ public class VamsasDatastore { /** * correctly creates provenance for trees calculated on an alignment by * jalview. - * + * * @param jal * @param tp * @return @@ -722,7 +722,7 @@ public class VamsasDatastore { prov.getEntry(0).getParam(0).setName("treeType"); prov.getEntry(0).getParam(0).setType("utf8"); prov.getEntry(0).getParam(0).setContent("NJ"); - + int ranges[] = tp.getTree().seqData.getVisibleContigs(); // VisibleContigs are with respect to alignment coordinates. Still need offsets int start= tp.getTree().seqData.getAlignmentOrigin(); @@ -739,7 +739,7 @@ public class VamsasDatastore { } /** - * + * * @param tp * @return Object[] { AlignmentView, AlignmentI - reference alignment for * input } @@ -795,7 +795,7 @@ public class VamsasDatastore { /** * get start0) { - // LOAD ALIGNMENTS from DATASET + // LOAD ALIGNMENTS from DATASET for (int al=0,nal=dataset.getAlignmentCount(); al0) { AnnotationElement ae[] = annotation.getAnnotationElement(); for (int aa = 0; aa < ae.length; aa++) { int pos = ae[aa].getPosition()-1;// pos counts from 1 to (|seg.start-seg.end|+1) - if (pos>=0 && pos=0 && pos 0) { int pos = dseta.getPos(0).getI(); @@ -1463,7 +1463,7 @@ public class VamsasDatastore { } return null; } - /* not needed now. + /* not needed now. * Provenance getVamsasProvenance(jalview.datamodel.Provenance jprov) { jalview.datamodel.ProvenanceEntry[] entries = null; // TODO: fix App and Action here. @@ -1519,7 +1519,7 @@ public class VamsasDatastore { } /** - * + * * @return default initial provenance list for a Jalview created vamsas * object. */ diff --git a/src/jalview/io/WSWUBlastClient.java b/src/jalview/io/WSWUBlastClient.java index 6a06f90..e2910ee 100755 --- a/src/jalview/io/WSWUBlastClient.java +++ b/src/jalview/io/WSWUBlastClient.java @@ -286,7 +286,7 @@ public class WSWUBlastClient Data inputs[] = new Data[1]; Data input= new Data(); input.setType("sequence"); - input.setContent(AlignSeq.extractGaps("-. ",sequence.getSequence())); + input.setContent(AlignSeq.extractGaps("-. ",sequence.getSequenceAsString())); inputs[0]=input; WSWUBlastService service = new WSWUBlastServiceLocator(); diff --git a/src/jalview/jbgui/GFinder.java b/src/jalview/jbgui/GFinder.java index 1a44c7f..b9bccc0 100755 --- a/src/jalview/jbgui/GFinder.java +++ b/src/jalview/jbgui/GFinder.java @@ -172,7 +172,8 @@ public class GFinder if(sequences!=null && sequences.length>0) { str = jalview.analysis.AlignSeq.extractGaps( - jalview.util.Comparison.GapChars, sequences[0].getSequence()); + jalview.util.Comparison.GapChars, + sequences[0].getSequenceAsString()); textfield.setText(str); } diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 4a78aa1..20b0885 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -126,7 +126,7 @@ public class AnnotationColourGradient extends ResidueColourScheme * * @return DOCUMENT ME! */ - public Color findColour(String n) + public Color findColour(char c) { return Color.red; } @@ -139,15 +139,15 @@ public class AnnotationColourGradient extends ResidueColourScheme * * @return DOCUMENT ME! */ - public Color findColour(String n, int j) + public Color findColour(char c, int j) { Color currentColour = Color.white; - if ((threshold == 0) || aboveThreshold(n, j)) + if ((threshold == 0) || aboveThreshold(c, j)) { if( j=annotationThreshold.value) @@ -155,7 +155,7 @@ public class AnnotationColourGradient extends ResidueColourScheme { if(colourScheme!=null) { - currentColour = colourScheme.findColour(n, j); + currentColour = colourScheme.findColour(c, j); } else if(range!=0) { diff --git a/src/jalview/schemes/Blosum62ColourScheme.java b/src/jalview/schemes/Blosum62ColourScheme.java index f2d2c98..02545a3 100755 --- a/src/jalview/schemes/Blosum62ColourScheme.java +++ b/src/jalview/schemes/Blosum62ColourScheme.java @@ -30,20 +30,18 @@ public class Blosum62ColourScheme super(); } - public Color findColour(String s, int j) + public Color findColour(char res, int j) { - - char res = s.charAt(0); if ('a' <= res && res <= 'z' ) { // TO UPPERCASE !!! - s = String.valueOf( res -= ('a' - 'A') ); + res -= ('a' - 'A'); } if (consensus == null || j >= consensus.length || consensus[j] == null || - (threshold != 0 && !aboveThreshold(s, j))) + (threshold != 0 && !aboveThreshold(res, j))) { return Color.white; } @@ -54,7 +52,7 @@ public class Blosum62ColourScheme { String max = (String) consensus[j].get(AAFrequency.MAXRESIDUE); - if (max.indexOf(s) > -1) + if (max.indexOf(res) > -1) { currentColour = new Color(154, 154, 255); } @@ -66,8 +64,8 @@ public class Blosum62ColourScheme do { - c += ResidueProperties.getBLOSUM62(max.substring(max_aa, - max_aa + 1), s); + c += ResidueProperties.getBLOSUM62( + max.charAt(max_aa), res); } while (++max_aa < n); diff --git a/src/jalview/schemes/ClustalxColourScheme.java b/src/jalview/schemes/ClustalxColourScheme.java index 4c20873..eaf2a5f 100755 --- a/src/jalview/schemes/ClustalxColourScheme.java +++ b/src/jalview/schemes/ClustalxColourScheme.java @@ -70,23 +70,23 @@ public class ClustalxColourScheme int res; int i; int j = 0; - String seq; + char [] seq; while (j < seqs.size()) { seq = ( (SequenceI) seqs.elementAt(j)).getSequence(); - int end_j = seq.length() - 1; + int end_j = seq.length - 1; for (i = start; i <= end_j; i++) { - if ( (seq.length() - 1) < i) + if ( (seq.length - 1) < i) { res = 23; } else { - res = ResidueProperties.aaIndex[seq.charAt(i)]; + res = ResidueProperties.aaIndex[seq[i]]; } cons2[i][res]++; @@ -240,22 +240,22 @@ public class ClustalxColourScheme ResidueColour[19] = colours[0]; // V } - public Color findColour(String s) + public Color findColour(char c) { return Color.pink; } - public Color findColour(String s, int j) + public Color findColour(char c, int j) { Color currentColour; - if ( cons2.length<=j || (threshold != 0 && !aboveThreshold(s, j))) + if ( cons2.length<=j || (threshold != 0 && !aboveThreshold(c, j))) { return Color.white; } - int i = ResidueProperties.aaIndex[s.charAt(0)]; + int i = ResidueProperties.aaIndex[c]; currentColour = Color.white; diff --git a/src/jalview/schemes/ColourSchemeI.java b/src/jalview/schemes/ColourSchemeI.java index da3093e..6afa3ef 100755 --- a/src/jalview/schemes/ColourSchemeI.java +++ b/src/jalview/schemes/ColourSchemeI.java @@ -22,9 +22,9 @@ import java.awt.*; public interface ColourSchemeI { - public Color findColour(String aa); + public Color findColour(char c); - public Color findColour(String s, int j); + public Color findColour(char c, int j); public void setConsensus(java.util.Hashtable [] h); diff --git a/src/jalview/schemes/NucleotideColourScheme.java b/src/jalview/schemes/NucleotideColourScheme.java index 4afb321..899fc60 100755 --- a/src/jalview/schemes/NucleotideColourScheme.java +++ b/src/jalview/schemes/NucleotideColourScheme.java @@ -44,10 +44,10 @@ public class NucleotideColourScheme extends ResidueColourScheme * * @return DOCUMENT ME! */ - public Color findColour(String n) + public Color findColour(char c) { // System.out.println("called"); log.debug - return colors[ResidueProperties.nucleotideIndex[n.charAt(0)]]; + return colors[ResidueProperties.nucleotideIndex[c]]; } /** @@ -58,14 +58,14 @@ public class NucleotideColourScheme extends ResidueColourScheme * * @return DOCUMENT ME! */ - public Color findColour(String n, int j) + public Color findColour(char c, int j) { Color currentColour; - if ((threshold == 0) || aboveThreshold(n, j)) + if ((threshold == 0) || aboveThreshold(c, j)) { try { - currentColour = colors[ ResidueProperties.nucleotideIndex[n.charAt(0)]]; + currentColour = colors[ ResidueProperties.nucleotideIndex[c]]; } catch (Exception ex) { diff --git a/src/jalview/schemes/PIDColourScheme.java b/src/jalview/schemes/PIDColourScheme.java index 9bd092e..8686894 100755 --- a/src/jalview/schemes/PIDColourScheme.java +++ b/src/jalview/schemes/PIDColourScheme.java @@ -36,12 +36,11 @@ public class PIDColourScheme this.thresholds = ResidueProperties.pidThresholds; } - public Color findColour(String s, int j) + public Color findColour(char c, int j) { - char res = s.charAt(0); - if ('a' <= res && res <= 'z') + if ('a' <= c && c <= 'z') { - s = String.valueOf(res -= ('a' - 'A')); + c -= ('a' - 'A'); } if (consensus == null @@ -51,7 +50,7 @@ public class PIDColourScheme return Color.white; } - if ( (threshold != 0) && !aboveThreshold(s, j)) + if ( (threshold != 0) && !aboveThreshold(c, j)) { return Color.white; } @@ -64,11 +63,11 @@ public class PIDColourScheme return Color.white; if ( (Integer.parseInt(consensus[j].get(AAFrequency.MAXCOUNT).toString()) != -1) && - consensus[j].contains(s)) + consensus[j].contains(String.valueOf(c))) { sc = ( (Float) consensus[j].get(ignoreGaps)).floatValue(); - if (!jalview.util.Comparison.isGap(res)) + if (!jalview.util.Comparison.isGap(c)) { for (int i = 0; i < thresholds.length; i++) { diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index b905c45..df90500 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -75,21 +75,20 @@ public class ResidueColourScheme implements ColourSchemeI /** * Find a colour without an index in a sequence */ - public Color findColour(String aa) + public Color findColour(char c) { - return colors[ResidueProperties.aaIndex[aa.charAt(0)]]; + return colors[ResidueProperties.aaIndex[c]]; } - public Color findColour(String s, int j) + public Color findColour(char c, int j) { Color currentColour; - int index = ResidueProperties.aaIndex[s.charAt(0)]; - if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j)) + if ((threshold == 0) || aboveThreshold(c, j)) { - currentColour = colors[index]; + currentColour = colors[ResidueProperties.aaIndex[c]]; } else { @@ -136,22 +135,20 @@ public class ResidueColourScheme implements ColourSchemeI * * @return DOCUMENT ME! */ - public boolean aboveThreshold(String s, int j) + public boolean aboveThreshold(char c, int j) { - char c = s.charAt(0); if ('a' <= c && c <= 'z') { // TO UPPERCASE !!! //Faster than toUpperCase c -= ('a' - 'A'); - s = String.valueOf(c); } if (consensus == null || consensus[j] == null) return false; if ( ( ( (Integer) consensus[j].get(AAFrequency.MAXCOUNT)).intValue() != -1) && - consensus[j].contains(s)) + consensus[j].contains(String.valueOf(c))) { if ( ( (Float) consensus[j].get(ignoreGaps)).floatValue() >= threshold) { diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index 4699dc6..1015073 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -1168,14 +1168,14 @@ public class ResidueProperties return pog; } - public static int getBLOSUM62(String A1, String A2) + public static int getBLOSUM62(char c1, char c2) { int pog = 0; try { - int a = aaIndex[A1.charAt(0)]; - int b = aaIndex[A2.charAt(0)]; + int a = aaIndex[c1]; + int b = aaIndex[c2]; pog = ResidueProperties.BLOSUM62[a][b]; } diff --git a/src/jalview/schemes/ScoreColourScheme.java b/src/jalview/schemes/ScoreColourScheme.java index 4cd9fd3..1c9525c 100755 --- a/src/jalview/schemes/ScoreColourScheme.java +++ b/src/jalview/schemes/ScoreColourScheme.java @@ -82,18 +82,16 @@ public class ScoreColourScheme extends ResidueColourScheme * * @return DOCUMENT ME! */ - public Color findColour(String s, int j) + public Color findColour(char c, int j) { if (threshold > 0) { - if (!aboveThreshold(s, j)) + if (!aboveThreshold(c, j)) { return Color.white; } } - char c = s.charAt(0); - if (jalview.util.Comparison.isGap(c)) { return Color.white; diff --git a/src/jalview/schemes/UserColourScheme.java b/src/jalview/schemes/UserColourScheme.java index c029b31..00f8f6f 100755 --- a/src/jalview/schemes/UserColourScheme.java +++ b/src/jalview/schemes/UserColourScheme.java @@ -186,14 +186,14 @@ public class UserColourScheme - public Color findColour(String s, int j) + public Color findColour(char c, int j) { Color currentColour; - int index = ResidueProperties.aaIndex[s.charAt(0)]; + int index = ResidueProperties.aaIndex[c]; - if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j)) + if ((threshold == 0) || aboveThreshold(c, j)) { - if(lowerCaseColours!=null && 'a' <= s.charAt(0) && s.charAt(0) <= 'z') + if(lowerCaseColours!=null && 'a' <= c && c <= 'z') currentColour = lowerCaseColours[index]; else currentColour = colors[index]; diff --git a/src/jalview/ws/JPredClient.java b/src/jalview/ws/JPredClient.java index a4d8b1f..863e80e 100755 --- a/src/jalview/ws/JPredClient.java +++ b/src/jalview/ws/JPredClient.java @@ -60,7 +60,7 @@ public class JPredClient * @param title String * @param msa boolean * @param alview AlignmentView - * @param viewonly if true then the prediction will be made just on the concatenated visible regions + * @param viewonly if true then the prediction will be made just on the concatenated visible regions */ private void startJPredClient(String title, boolean msa, jalview.datamodel.AlignmentView alview, AlignFrame parentFrame, boolean viewonly) @@ -89,13 +89,13 @@ public class JPredClient int spos=0; int i=0; if (viscontigs!=null) { - // Construct the delMap - mapping from the positions within the input to Jnet to the contigs in the original sequence - + // Construct the delMap - mapping from the positions within the input to Jnet to the contigs in the original sequence + delMap = new int[seq.getEnd()-seq.getStart()+1]; int gapMap[] = seq.gapMap(); for (int contig = 0; contig 1) { - + String altitle = "JNet prediction on "+(viewonly?"visible ":"") + seq.getName() + " using alignment from " + title; @@ -119,22 +119,22 @@ public class JPredClient { aln[i] = msf[i].getSeq('-'); } - - + + Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln, true); if (viewonly) { // Remove hidden regions from sequence objects. String seqs[] = alview.getSequenceStrings('-'); for (int i = 0, j = msf.length; i < j; i++) - { + { aln[i].setSequence(seqs[i]); - } + } seq.setSequence(seqs[0]); - } + } wsInfo.setProgressText("Job details for "+(viewonly?"visible ":"")+"MSA based prediction (" + title + ") on sequence :\n>" + seq.getName() + "\n" + - AlignSeq.extractGaps("-. ", seq.getSequence()) + + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n"); JPredThread jthread = new JPredThread(wsInfo, altitle, server, SequenceInfo, aln, delMap, alview, parentFrame, WsURL); @@ -155,10 +155,10 @@ public class JPredClient // Remove hidden regions from input sequence String seqs[] = alview.getSequenceStrings('-'); seq.setSequence(seqs[0]); - } + } wsInfo.setProgressText("Job details for prediction on "+(viewonly?"visible ":"")+"sequence :\n>" + seqname + "\n" + - AlignSeq.extractGaps("-. ", seq.getSequence()) + + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n"); JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL, SequenceInfo, seq, delMap, alview, parentFrame); @@ -203,7 +203,7 @@ public class JPredClient wsInfo.setProgressText("Job details for MSA based prediction (" + title + ") on sequence :\n>" + seq.getName() + "\n" + - AlignSeq.extractGaps("-. ", seq.getSequence()) + + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n"); SequenceI aln[] = new SequenceI[msf.length]; for (int i = 0, j = msf.length; i < j; i++) @@ -232,7 +232,7 @@ public class JPredClient } wsInfo.setProgressText("Job details for prediction on sequence :\n>" + seq.getName() + "\n" + - AlignSeq.extractGaps("-. ", seq.getSequence()) + + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n"); String altitle = "JNet prediction for sequence " + seq.getName() + " from " + title; diff --git a/src/jalview/ws/JPredThread.java b/src/jalview/ws/JPredThread.java index 15b8bd8..f2592ff 100644 --- a/src/jalview/ws/JPredThread.java +++ b/src/jalview/ws/JPredThread.java @@ -142,7 +142,7 @@ implements WSClientI gc); SequenceI profileseq=al.getSequenceAt(FirstSeq); - profileseq.setSequence(sqs[msaIndex].getSequence()); + profileseq.setSequence(sqs[msaIndex].getSequenceAsString()); } if (!jalview.analysis.SeqsetUtils.SeqCharacterUnhash( @@ -181,7 +181,7 @@ implements WSClientI sb.append(gc); } for (int s=1,ns=al.getHeight(); s0) { // pad gaps @@ -225,7 +225,7 @@ implements WSClientI for (int s=0,ns=al.getHeight(); s0) { @@ -268,7 +268,8 @@ implements WSClientI { super(); this.predMap = delMap; - String sq = AlignSeq.extractGaps(Comparison.GapChars, seq.getSequence()); + String sq = AlignSeq.extractGaps(Comparison.GapChars, + seq.getSequenceAsString()); if (sq.length() >= 20) { this.SequenceInfo = SequenceInfo; diff --git a/src/jalview/ws/MsaWSThread.java b/src/jalview/ws/MsaWSThread.java index 3fd5fbc..cd14a24 100644 --- a/src/jalview/ws/MsaWSThread.java +++ b/src/jalview/ws/MsaWSThread.java @@ -127,20 +127,20 @@ class MsaWSThread { seqarray[n] = new vamsas.objects.simple.Sequence(); seqarray[n].setId(newname); - seqarray[n++].setSeq( (submitGaps) ? seqs[i].getSequence() + seqarray[n++].setSeq( (submitGaps) ? seqs[i].getSequenceAsString() : AlignSeq.extractGaps( jalview.util.Comparison.GapChars, seqs[i] - .getSequence())); + .getSequenceAsString())); } else { String empty = null; if (seqs[i].getEnd() >= seqs[i].getStart()) { - empty = (submitGaps) ? seqs[i].getSequence() + empty = (submitGaps) ? seqs[i].getSequenceAsString() : AlignSeq.extractGaps( jalview.util.Comparison.GapChars, seqs[i] - .getSequence()); + .getSequenceAsString()); } emptySeqs.add(new String[] {newname, empty});