X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fio%2FAlignFile.java;h=0691d82d47e10dd93bb8721fb3866f8ce860a917;hb=b45345a4ee49f07b6f66e80535ca5f140a954e41;hp=d22dc12affec96ce09f97bd011adf368f81bb256;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/io/AlignFile.java b/src/jalview/io/AlignFile.java index d22dc12..0691d82 100755 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle +* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -39,6 +39,7 @@ public abstract class AlignFile extends FileParse Vector headers; long start; long end; + boolean jvSuffix = true; /** * Creates a new AlignFile object. @@ -47,24 +48,6 @@ public abstract class AlignFile extends FileParse { } - /** - * Creates a new AlignFile object. - * - * @param inStr DOCUMENT ME! - */ - public AlignFile(String inStr) - { - initData(); - System.out.println("is this ever called??"); - - try - { - parse(); - } - catch (Exception ex) - { - } - } /** * Constructor which parses the data from a file of some specified type. @@ -131,15 +114,17 @@ public abstract class AlignFile extends FileParse protected boolean isValidProteinSequence(String sequence) { for (int i = 0; i < sequence.length(); i++) - if (!jalview.schemes.ResidueProperties.aaHash.containsKey( - String.valueOf(sequence.charAt(i)))) + if (jalview.schemes.ResidueProperties.aaIndex[sequence.charAt(i)]==-1) { + invalidCharacter = sequence.charAt(i); return false; } return true; } + char invalidCharacter; + /** * This method must be implemented to parse the contents of the file. */ @@ -149,4 +134,45 @@ public abstract class AlignFile extends FileParse * Print out in alignment file format the Sequences in the seqs Vector. */ public abstract String print(); + + public void addJVSuffix(boolean b) + { + jvSuffix = b; + } + + /** + * A general parser for ids. + * + * @String id Id to be parsed + */ + Sequence parseId(String id) + { + Sequence seq = null; + id = id.trim(); + int space = id.indexOf(" "); + if(space>-1) + { + seq = new Sequence(id.substring(0, space),""); + seq.setDescription(id.substring(space+1)); + } + else + { + seq = new Sequence(id, ""); + } + + return seq; + } + + /** + * Creates the output id. + * Adds prefix Uniprot format source|id + * And suffix Jalview /start-end + * + * @String id Id to be parsed + */ + String printId(SequenceI seq) + { + return seq.getDisplayId(jvSuffix); + } + }