2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
\r
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
25 import jalview.analysis.*;
\r
26 import jalview.datamodel.*;
\r
27 import jalview.schemes.*;
\r
29 public class AnnotationFile
\r
31 StringBuffer text = new StringBuffer("JALVIEW_ANNOTATION\n"
\r
32 + "# Created: " + new java.util.Date() + "\n\n");
\r
35 * convenience method for pre-2.4 feature files which have no view, hidden
\r
36 * columns or hidden row keywords.
\r
38 * @param annotations
\r
41 * @return feature file as a string.
\r
43 public String printAnnotations(AlignmentAnnotation[] annotations,
\r
44 Vector groups, Hashtable properties)
\r
46 return printAnnotations(annotations, groups, properties, null);
\r
51 * hold all the information about a particular view definition read from or
\r
52 * written out in an annotations file.
\r
54 public class ViewDef
\r
56 public String viewname;
\r
58 public HiddenSequences hidseqs;
\r
60 public ColumnSelection hiddencols;
\r
62 public Vector visibleGroups;
\r
64 public ViewDef(String viewname, HiddenSequences hidseqs,
\r
65 ColumnSelection hiddencols)
\r
67 this.viewname = viewname;
\r
68 this.hidseqs = hidseqs;
\r
69 this.hiddencols = hiddencols;
\r
73 public String printAnnotations(AlignmentAnnotation[] annotations,
\r
74 Vector groups, Hashtable properties, ViewDef[] views)
\r
76 if (annotations != null)
\r
78 boolean oneColour = true;
\r
79 AlignmentAnnotation row;
\r
81 SequenceI refSeq = null;
\r
83 StringBuffer colours = new StringBuffer();
\r
84 StringBuffer graphLine = new StringBuffer();
\r
86 Hashtable graphGroup = new Hashtable();
\r
88 java.awt.Color color;
\r
90 for (int i = 0; i < annotations.length; i++)
\r
92 row = annotations[i];
\r
94 if (!row.visible && !row.hasScore())
\r
102 if (row.sequenceRef == null)
\r
104 if (refSeq != null)
\r
106 text.append("\nSEQUENCE_REF\tALIGNMENT\n");
\r
112 else if (refSeq == null || refSeq != row.sequenceRef)
\r
114 refSeq = row.sequenceRef;
\r
115 text.append("\nSEQUENCE_REF\t" + refSeq.getName() + "\n");
\r
118 if (row.graph == AlignmentAnnotation.NO_GRAPH)
\r
120 text.append("NO_GRAPH\t");
\r
124 if (row.graph == AlignmentAnnotation.BAR_GRAPH)
\r
126 text.append("BAR_GRAPH\t");
\r
128 else if (row.graph == AlignmentAnnotation.LINE_GRAPH)
\r
130 text.append("LINE_GRAPH\t");
\r
133 if (row.getThreshold() != null)
\r
136 .append("GRAPHLINE\t"
\r
139 + row.getThreshold().value
\r
141 + row.getThreshold().label
\r
143 + jalview.util.Format.getHexString(row
\r
144 .getThreshold().colour) + "\n");
\r
147 if (row.graphGroup > -1)
\r
149 String key = String.valueOf(row.graphGroup);
\r
150 if (graphGroup.containsKey(key))
\r
152 graphGroup.put(key, graphGroup.get(key) + "\t" + row.label);
\r
156 graphGroup.put(key, row.label);
\r
161 text.append(row.label + "\t");
\r
162 if (row.description != null)
\r
164 text.append(row.description + "\t");
\r
167 for (int j = 0; row.annotations != null
\r
168 && j < row.annotations.length; j++)
\r
171 && jalview.util.Comparison.isGap(refSeq.getCharAt(j)))
\r
176 if (row.annotations[j] != null)
\r
179 if (row.annotations[j].secondaryStructure != ' ')
\r
181 text.append(comma + row.annotations[j].secondaryStructure);
\r
184 if (row.annotations[j].displayCharacter != null
\r
185 && row.annotations[j].displayCharacter.length() > 0
\r
186 && !row.annotations[j].displayCharacter.equals(" "))
\r
188 text.append(comma + row.annotations[j].displayCharacter);
\r
192 if (row.annotations[j] != null)
\r
194 if (color != null && !color.equals(row.annotations[j].colour))
\r
199 color = row.annotations[j].colour;
\r
200 if (row.annotations[j].value != 0f
\r
201 && row.annotations[j].value != Float.NaN)
\r
203 text.append(comma + row.annotations[j].value);
\r
207 if (row.annotations[j].colour != null
\r
208 && row.annotations[j].colour != java.awt.Color.black)
\r
212 + jalview.util.Format
\r
213 .getHexString(row.annotations[j].colour)
\r
220 if (row.hasScore())
\r
221 text.append("\t" + row.score);
\r
225 if (color != null && color != java.awt.Color.black && oneColour)
\r
227 colours.append("COLOUR\t" + row.label + "\t"
\r
228 + jalview.util.Format.getHexString(color) + "\n");
\r
235 text.append(colours.toString());
\r
236 text.append(graphLine.toString());
\r
237 if (graphGroup.size() > 0)
\r
239 text.append("COMBINE\t");
\r
240 Enumeration en = graphGroup.elements();
\r
241 while (en.hasMoreElements())
\r
243 text.append(en.nextElement() + "\n");
\r
248 if (groups != null)
\r
250 printGroups(groups);
\r
253 if (properties != null)
\r
255 text.append("\n\nALIGNMENT");
\r
256 Enumeration en = properties.keys();
\r
257 while (en.hasMoreElements())
\r
259 String key = en.nextElement().toString();
\r
260 text.append("\t" + key + "=" + properties.get(key));
\r
265 return text.toString();
\r
268 public void printGroups(Vector sequenceGroups)
\r
271 for (int i = 0; i < sequenceGroups.size(); i++)
\r
273 sg = (SequenceGroup) sequenceGroups.elementAt(i);
\r
274 text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t"
\r
275 + (sg.getStartRes() + 1) + "\t" + (sg.getEndRes() + 1) + "\t"
\r
277 for (int s = 0; s < sg.getSize(); s++)
\r
279 text.append(sg.getSequenceAt(s).getName() + "\t");
\r
282 text.append("\nPROPERTIES\t" + sg.getName() + "\t");
\r
284 if (sg.getDescription() != null)
\r
286 text.append("description=" + sg.getDescription() + "\t");
\r
290 text.append("colour=" + ColourSchemeProperty.getColourName(sg.cs)
\r
292 if (sg.cs.getThreshold() != 0)
\r
294 text.append("pidThreshold=" + sg.cs.getThreshold());
\r
296 if (sg.cs.conservationApplied())
\r
298 text.append("consThreshold=" + sg.cs.getConservationInc() + "\t");
\r
301 text.append("outlineColour="
\r
302 + jalview.util.Format.getHexString(sg.getOutlineColour())
\r
305 text.append("displayBoxes=" + sg.getDisplayBoxes() + "\t");
\r
306 text.append("displayText=" + sg.getDisplayText() + "\t");
\r
307 text.append("colourText=" + sg.getColourText() + "\t");
\r
309 if (sg.textColour != java.awt.Color.black)
\r
311 text.append("textCol1="
\r
312 + jalview.util.Format.getHexString(sg.textColour) + "\t");
\r
314 if (sg.textColour2 != java.awt.Color.white)
\r
316 text.append("textCol2="
\r
317 + jalview.util.Format.getHexString(sg.textColour2) + "\t");
\r
319 if (sg.thresholdTextColour != 0)
\r
321 text.append("textColThreshold=" + sg.thresholdTextColour);
\r
323 if (sg.idColour != null)
\r
325 text.append("idColour="
\r
326 + jalview.util.Format.getHexString(sg.idColour) + "\t");
\r
329 text.append("\n\n");
\r
334 SequenceI refSeq = null;
\r
336 String refSeqId = null;
\r
338 public boolean readAnnotationFile(AlignmentI al, String file,
\r
343 BufferedReader in = null;
\r
344 if (protocol.equals(AppletFormatAdapter.FILE))
\r
346 in = new BufferedReader(new FileReader(file));
\r
348 else if (protocol.equals(AppletFormatAdapter.URL))
\r
350 URL url = new URL(file);
\r
351 in = new BufferedReader(new InputStreamReader(url.openStream()));
\r
353 else if (protocol.equals(AppletFormatAdapter.PASTE))
\r
355 in = new BufferedReader(new StringReader(file));
\r
357 else if (protocol.equals(AppletFormatAdapter.CLASSLOADER))
\r
359 java.io.InputStream is = getClass().getResourceAsStream("/" + file);
\r
362 in = new BufferedReader(new java.io.InputStreamReader(is));
\r
366 String line, label, description, token;
\r
367 int graphStyle, index;
\r
368 int refSeqIndex = 1;
\r
369 int existingAnnotations = 0;
\r
370 if (al.getAlignmentAnnotation() != null)
\r
372 existingAnnotations = al.getAlignmentAnnotation().length;
\r
375 int alWidth = al.getWidth();
\r
377 StringTokenizer st;
\r
378 Annotation[] annotations;
\r
379 AlignmentAnnotation annotation = null;
\r
381 // First confirm this is an Annotation file
\r
382 boolean jvAnnotationFile = false;
\r
383 while ((line = in.readLine()) != null)
\r
385 if (line.indexOf("#") == 0)
\r
390 if (line.indexOf("JALVIEW_ANNOTATION") > -1)
\r
392 jvAnnotationFile = true;
\r
397 if (!jvAnnotationFile)
\r
403 while ((line = in.readLine()) != null)
\r
405 if (line.indexOf("#") == 0
\r
406 || line.indexOf("JALVIEW_ANNOTATION") > -1
\r
407 || line.length() == 0)
\r
412 st = new StringTokenizer(line, "\t");
\r
413 token = st.nextToken();
\r
414 if (token.equalsIgnoreCase("COLOUR"))
\r
416 colourAnnotations(al, st.nextToken(), st.nextToken());
\r
420 else if (token.equalsIgnoreCase("COMBINE"))
\r
422 combineAnnotations(al, st);
\r
426 else if (token.equalsIgnoreCase("GRAPHLINE"))
\r
432 else if (token.equalsIgnoreCase("SEQUENCE_REF"))
\r
434 if (st.hasMoreTokens())
\r
436 refSeq = al.findName(refSeqId = st.nextToken());
\r
437 if (refSeq == null)
\r
443 refSeqIndex = Integer.parseInt(st.nextToken());
\r
444 if (refSeqIndex < 1)
\r
448 .println("WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile");
\r
450 } catch (Exception ex)
\r
463 else if (token.equalsIgnoreCase("SEQUENCE_GROUP"))
\r
469 else if (token.equalsIgnoreCase("PROPERTIES"))
\r
471 addProperties(al, st);
\r
475 else if (token.equalsIgnoreCase("BELOW_ALIGNMENT"))
\r
477 setBelowAlignment(al, st);
\r
480 else if (token.equalsIgnoreCase("ALIGNMENT"))
\r
482 addAlignmentDetails(al, st);
\r
486 graphStyle = AlignmentAnnotation.getGraphValueFromString(token);
\r
487 label = st.nextToken();
\r
490 annotations = new Annotation[alWidth];
\r
491 description = null;
\r
492 float score = Float.NaN;
\r
494 if (st.hasMoreTokens())
\r
496 line = st.nextToken();
\r
498 if (line.indexOf("|") == -1)
\r
500 description = line;
\r
501 if (st.hasMoreTokens())
\r
502 line = st.nextToken();
\r
505 if (st.hasMoreTokens())
\r
507 // This must be the score
\r
508 score = Float.valueOf(st.nextToken()).floatValue();
\r
511 st = new StringTokenizer(line, "|", true);
\r
513 boolean emptyColumn = true;
\r
514 boolean onlyOneElement = (st.countTokens() == 1);
\r
516 while (st.hasMoreElements() && index < alWidth)
\r
518 token = st.nextToken().trim();
\r
520 if (onlyOneElement)
\r
524 score = Float.valueOf(token).floatValue();
\r
526 } catch (NumberFormatException ex)
\r
531 if (token.equals("|"))
\r
538 emptyColumn = true;
\r
542 annotations[index++] = parseAnnotation(token);
\r
543 emptyColumn = false;
\r
549 annotation = new AlignmentAnnotation(label, description,
\r
550 (index == 0) ? null : annotations, 0, 0, graphStyle);
\r
552 annotation.score = score;
\r
554 if (refSeq != null)
\r
556 annotation.belowAlignment = false;
\r
559 // copy before we do any mapping business.
\r
560 // TODO: verify that undo/redo with 1:many sequence associated
\r
561 // annotations can be undone correctly
\r
562 AlignmentAnnotation ann = new AlignmentAnnotation(annotation);
\r
563 annotation.createSequenceMapping(refSeq, refSeqIndex, false);
\r
564 annotation.adjustForAlignment();
\r
565 refSeq.addAlignmentAnnotation(annotation);
\r
566 al.addAnnotation(annotation);
\r
567 al.setAnnotationIndex(annotation,
\r
568 al.getAlignmentAnnotation().length
\r
569 - existingAnnotations - 1);
\r
570 // and recover our virgin copy to use again if necessary.
\r
573 } while (refSeqId != null
\r
574 && (refSeq = al.findName(refSeq, refSeqId, true)) != null);
\r
578 al.addAnnotation(annotation);
\r
579 al.setAnnotationIndex(annotation,
\r
580 al.getAlignmentAnnotation().length - existingAnnotations
\r
585 } catch (Exception ex)
\r
587 ex.printStackTrace();
\r
588 System.out.println("Problem reading annotation file: " + ex);
\r
594 Annotation parseAnnotation(String string)
\r
596 String desc = null, displayChar = null;
\r
597 char ss = ' '; // secondaryStructure
\r
599 boolean parsedValue = false;
\r
601 // find colour here
\r
602 java.awt.Color colour = null;
\r
603 int i = string.indexOf("[");
\r
604 int j = string.indexOf("]");
\r
605 if (i > -1 && j > -1)
\r
607 UserColourScheme ucs = new UserColourScheme();
\r
609 colour = ucs.getColourFromString(string.substring(i + 1, j));
\r
611 string = string.substring(0, i) + string.substring(j + 1);
\r
614 StringTokenizer st = new StringTokenizer(string, ",");
\r
616 while (st.hasMoreTokens())
\r
618 token = st.nextToken().trim();
\r
619 if (token.length() == 0)
\r
628 displayChar = token;
\r
629 value = new Float(token).floatValue();
\r
630 parsedValue = true;
\r
632 } catch (NumberFormatException ex)
\r
637 if (token.equals("H") || token.equals("E"))
\r
639 // Either this character represents a helix or sheet
\r
640 // or an integer which can be displayed
\r
641 ss = token.charAt(0);
\r
642 if (displayChar.equals(token.substring(0, 1)))
\r
647 else if (desc == null)
\r
654 if (displayChar != null && displayChar.length() > 1 && desc != null
\r
655 && desc.length() == 1)
\r
657 String tmp = displayChar;
\r
658 displayChar = desc;
\r
662 * In principle, this code will ensure that the Annotation element generated
\r
663 * is renderable by any of the applet or application rendering code but
\r
664 * instead we check for null strings when the display character is rendered.
\r
665 * if (displayChar==null) { displayChar=""; }
\r
667 Annotation anot = new Annotation(displayChar, desc, ss, value);
\r
669 anot.colour = colour;
\r
674 void colourAnnotations(AlignmentI al, String label, String colour)
\r
676 UserColourScheme ucs = new UserColourScheme(colour);
\r
677 Annotation[] annotations;
\r
678 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
680 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(label))
\r
682 annotations = al.getAlignmentAnnotation()[i].annotations;
\r
683 for (int j = 0; j < annotations.length; j++)
\r
685 if (annotations[j] != null)
\r
687 annotations[j].colour = ucs.findColour('A');
\r
694 void combineAnnotations(AlignmentI al, StringTokenizer st)
\r
696 int graphGroup = -1;
\r
697 String group = st.nextToken();
\r
698 // First make sure we are not overwriting the graphIndex
\r
699 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
701 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
703 graphGroup = al.getAlignmentAnnotation()[i].graphGroup + 1;
\r
704 al.getAlignmentAnnotation()[i].graphGroup = graphGroup;
\r
709 // Now update groups
\r
710 while (st.hasMoreTokens())
\r
712 group = st.nextToken();
\r
713 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
715 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
717 al.getAlignmentAnnotation()[i].graphGroup = graphGroup;
\r
724 void addLine(AlignmentI al, StringTokenizer st)
\r
726 String group = st.nextToken();
\r
727 AlignmentAnnotation annotation = null;
\r
729 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
731 if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))
\r
733 annotation = al.getAlignmentAnnotation()[i];
\r
738 if (annotation == null)
\r
742 float value = new Float(st.nextToken()).floatValue();
\r
743 String label = st.hasMoreTokens() ? st.nextToken() : null;
\r
744 java.awt.Color colour = null;
\r
745 if (st.hasMoreTokens())
\r
747 UserColourScheme ucs = new UserColourScheme(st.nextToken());
\r
748 colour = ucs.findColour('A');
\r
751 annotation.setThreshold(new GraphLine(value, label, colour));
\r
754 void addGroup(AlignmentI al, StringTokenizer st)
\r
756 SequenceGroup sg = new SequenceGroup();
\r
757 sg.setName(st.nextToken());
\r
758 sg.setStartRes(Integer.parseInt(st.nextToken()) - 1);
\r
759 sg.setEndRes(Integer.parseInt(st.nextToken()) - 1);
\r
761 String index = st.nextToken();
\r
762 if (index.equals("-1"))
\r
764 while (st.hasMoreElements())
\r
766 sg.addSequence(al.findName(st.nextToken()), false);
\r
771 StringTokenizer st2 = new StringTokenizer(index, ",");
\r
773 while (st2.hasMoreTokens())
\r
775 String tmp = st2.nextToken();
\r
776 if (tmp.equals("*"))
\r
778 for (int i = 0; i < al.getHeight(); i++)
\r
780 sg.addSequence(al.getSequenceAt(i), false);
\r
783 else if (tmp.indexOf("-") >= 0)
\r
785 StringTokenizer st3 = new StringTokenizer(tmp, "-");
\r
787 int start = (Integer.parseInt(st3.nextToken()));
\r
788 int end = (Integer.parseInt(st3.nextToken()));
\r
792 for (int i = start; i <= end; i++)
\r
794 sg.addSequence(al.getSequenceAt(i - 1), false);
\r
801 .addSequence(al.getSequenceAt(Integer.parseInt(tmp) - 1),
\r
807 if (refSeq != null)
\r
809 sg.setStartRes(refSeq.findIndex(sg.getStartRes() + 1) - 1);
\r
810 sg.setEndRes(refSeq.findIndex(sg.getEndRes() + 1) - 1);
\r
813 if (sg.getSize() > 0)
\r
819 void addProperties(AlignmentI al, StringTokenizer st)
\r
822 // So far we have only added groups to the annotationHash,
\r
823 // the idea is in the future properties can be added to
\r
824 // alignments, other annotations etc
\r
825 if (al.getGroups() == null)
\r
829 SequenceGroup sg = null;
\r
831 String name = st.nextToken();
\r
833 Vector groups = al.getGroups();
\r
834 for (int i = 0; i < groups.size(); i++)
\r
836 sg = (SequenceGroup) groups.elementAt(i);
\r
837 if (sg.getName().equals(name))
\r
849 String keyValue, key, value;
\r
850 ColourSchemeI def = sg.cs;
\r
852 while (st.hasMoreTokens())
\r
854 keyValue = st.nextToken();
\r
855 key = keyValue.substring(0, keyValue.indexOf("="));
\r
856 value = keyValue.substring(keyValue.indexOf("=") + 1);
\r
858 if (key.equalsIgnoreCase("description"))
\r
860 sg.setDescription(value);
\r
862 else if (key.equalsIgnoreCase("colour"))
\r
864 sg.cs = ColourSchemeProperty.getColour(al, value);
\r
866 else if (key.equalsIgnoreCase("pidThreshold"))
\r
868 sg.cs.setThreshold(Integer.parseInt(value), true);
\r
871 else if (key.equalsIgnoreCase("consThreshold"))
\r
873 sg.cs.setConservationInc(Integer.parseInt(value));
\r
874 Conservation c = new Conservation("Group",
\r
875 ResidueProperties.propHash, 3, sg.getSequences(null), sg
\r
876 .getStartRes(), sg.getEndRes() + 1);
\r
879 c.verdict(false, 25);
\r
881 sg.cs.setConservation(c);
\r
884 else if (key.equalsIgnoreCase("outlineColour"))
\r
886 sg.setOutlineColour(new UserColourScheme(value).findColour('A'));
\r
888 else if (key.equalsIgnoreCase("displayBoxes"))
\r
890 sg.setDisplayBoxes(Boolean.valueOf(value).booleanValue());
\r
892 else if (key.equalsIgnoreCase("displayText"))
\r
894 sg.setDisplayText(Boolean.valueOf(value).booleanValue());
\r
896 else if (key.equalsIgnoreCase("colourText"))
\r
898 sg.setColourText(Boolean.valueOf(value).booleanValue());
\r
900 else if (key.equalsIgnoreCase("textCol1"))
\r
902 sg.textColour = new UserColourScheme(value).findColour('A');
\r
904 else if (key.equalsIgnoreCase("textCol2"))
\r
906 sg.textColour2 = new UserColourScheme(value).findColour('A');
\r
908 else if (key.equalsIgnoreCase("textColThreshold"))
\r
910 sg.thresholdTextColour = Integer.parseInt(value);
\r
912 else if (key.equalsIgnoreCase("idColour"))
\r
914 // consider warning if colour doesn't resolve to a real colour
\r
915 sg.setIdColour((def = new UserColourScheme(value))
\r
918 sg.recalcConservation();
\r
927 void setBelowAlignment(AlignmentI al, StringTokenizer st)
\r
930 AlignmentAnnotation aa;
\r
931 while (st.hasMoreTokens())
\r
933 token = st.nextToken();
\r
934 for (int i = 0; i < al.getAlignmentAnnotation().length; i++)
\r
936 aa = al.getAlignmentAnnotation()[i];
\r
937 if (aa.sequenceRef == refSeq && aa.label.equals(token))
\r
939 aa.belowAlignment = true;
\r
945 void addAlignmentDetails(AlignmentI al, StringTokenizer st)
\r
947 String keyValue, key, value;
\r
948 while (st.hasMoreTokens())
\r
950 keyValue = st.nextToken();
\r
951 key = keyValue.substring(0, keyValue.indexOf("="));
\r
952 value = keyValue.substring(keyValue.indexOf("=") + 1);
\r
953 al.setProperty(key, value);
\r
958 * Write annotations as a CSV file of the form 'label, value, value, ...' for
\r
961 * @param annotations
\r
962 * @return CSV file as a string.
\r
964 public String printCSVAnnotations(AlignmentAnnotation[] annotations)
\r
966 StringBuffer sp = new StringBuffer();
\r
967 for (int i = 0; i < annotations.length; i++)
\r
969 String atos = annotations[i].toString();
\r
973 int cp = atos.indexOf("\n", p);
\r
974 sp.append(annotations[i].label);
\r
978 sp.append(atos.substring(p, cp + 1));
\r
982 sp.append(atos.substring(p));
\r
988 return sp.toString();
\r