git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Don't parse input id, leave it as it is
[jalview.git]
/
src
/
jalview
/
io
/
PIRFile.java
diff --git
a/src/jalview/io/PIRFile.java
b/src/jalview/io/PIRFile.java
index
be60a43
..
d4b818b
100755
(executable)
--- a/
src/jalview/io/PIRFile.java
+++ b/
src/jalview/io/PIRFile.java
@@
-1,5
+1,6
@@
-/* Jalview - a java multiple alignment editor
\r
- * Copyright (C) 1998 Michele Clamp
\r
+/*
\r
+ * Jalview - A Sequence Alignment Editor and Viewer
\r
+ * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
*
\r
* This program is free software; you can redistribute it and/or
\r
* modify it under the terms of the GNU General Public License
\r
*
\r
* This program is free software; you can redistribute it and/or
\r
* modify it under the terms of the GNU General Public License
\r
@@
-13,121
+14,135
@@
*
\r
* You should have received a copy of the GNU General Public License
\r
* along with this program; if not, write to the Free Software
\r
*
\r
* You should have received a copy of the GNU General Public License
\r
* along with this program; if not, write to the Free Software
\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
*/
\r
package jalview.io;
\r
\r
*/
\r
package jalview.io;
\r
\r
-import jalview.datamodel.*;
\r
-import jalview.analysis.*;
\r
-
\r
import java.io.*;
\r
import java.util.*;
\r
\r
import java.io.*;
\r
import java.util.*;
\r
\r
-public class PIRFile extends AlignFile {
\r
+import jalview.analysis.*;
\r
+import jalview.datamodel.*;
\r
\r
\r
- Vector words = new Vector(); //Stores the words in a line after splitting
\r
+public class PIRFile
\r
+ extends AlignFile
\r
+{
\r
+ Vector words = new Vector(); //Stores the words in a line after splitting
\r
\r
public PIRFile()
\r
\r
public PIRFile()
\r
- {}
\r
+ {
\r
+ }
\r
\r
\r
- public PIRFile(String inStr) {
\r
+ public PIRFile(String inStr)
\r
+ {
\r
super(inStr);
\r
}
\r
\r
super(inStr);
\r
}
\r
\r
- public PIRFile(String inFile, String type) throws IOException {
\r
- super(inFile,type);
\r
+ public PIRFile(String inFile, String type)
\r
+ throws IOException
\r
+ {
\r
+ super(inFile, type);
\r
}
\r
\r
}
\r
\r
- public void parse() {
\r
- try{
\r
- String id, start, end;
\r
+ public void parse()
\r
+ {
\r
+ try
\r
+ {
\r
StringBuffer sequence;
\r
String line = null;
\r
StringBuffer sequence;
\r
String line = null;
\r
- while( (line = nextLine())!=null)
\r
+
\r
+ while ( (line = nextLine()) != null)
\r
{
\r
{
\r
- try{
\r
- id = line.substring(line.indexOf(";") + 1, line.indexOf("/"));
\r
- line = line.substring(line.indexOf("/") + 1);
\r
- start = line.substring(0, line.indexOf("-"));
\r
- end = line.substring(line.indexOf("-") + 1);
\r
- }catch(Exception ex)
\r
- { id="No id"; start="0"; end="0"; }
\r
+ if(line.length()==0)
\r
+ {
\r
+ //System.out.println("blank line");
\r
+ continue;
\r
+ }
\r
+
\r
+ Sequence newSeq = parseId(line.substring(line.indexOf(";") + 1));
\r
\r
sequence = new StringBuffer();
\r
\r
\r
sequence = new StringBuffer();
\r
\r
- line = nextLine(); // this is the title line
\r
+ newSeq.setDescription(nextLine()); // this is the title line
\r
\r
boolean starFound = false;
\r
\r
boolean starFound = false;
\r
- do
\r
+
\r
+ while(!starFound)
\r
{
\r
line = nextLine();
\r
{
\r
line = nextLine();
\r
- sequence.append( line );
\r
- if(line.indexOf("*")>-1)
\r
- starFound = true;
\r
+ sequence.append(line);
\r
\r
\r
- }while(!starFound);
\r
+ if (line == null)
\r
+ break;
\r
\r
\r
- sequence.setLength( sequence.length()-1);
\r
+ if (line.indexOf("*") > -1)
\r
+ {
\r
+ starFound = true;
\r
+ }
\r
+ }
\r
\r
\r
- Sequence newSeq = new Sequence(id,
\r
- sequence.toString(),
\r
- Integer.parseInt(start),
\r
- Integer.parseInt(end));
\r
- seqs.addElement(newSeq);
\r
- }
\r
+ if(sequence.length()>0)
\r
+ {
\r
+ sequence.setLength(sequence.length() - 1);
\r
\r
\r
+ newSeq.setSequence(sequence.toString());
\r
+ seqs.addElement(newSeq);
\r
+ }
\r
+ }
\r
+ }
\r
+ catch (Exception ex)
\r
+ {
\r
+ ex.printStackTrace();
\r
}
\r
}
\r
- catch(Exception ex){ex.printStackTrace();}
\r
}
\r
\r
}
\r
\r
- public String print() {
\r
+ public String print()
\r
+ {
\r
return print(getSeqsAsArray());
\r
}
\r
return print(getSeqsAsArray());
\r
}
\r
- public static String print(SequenceI[] s) {
\r
- return print(s,72,true);
\r
- }
\r
- public static String print(SequenceI[] s, int len) {
\r
- return print(s,len,true);
\r
- }
\r
- public static String print(SequenceI[] s, int len,boolean gaps) {
\r
+
\r
+ public String print(SequenceI[] s)
\r
+ {
\r
+ boolean is_NA = jalview.util.Comparison.isNucleotide(s);
\r
+ int len = 72;
\r
StringBuffer out = new StringBuffer();
\r
int i = 0;
\r
\r
StringBuffer out = new StringBuffer();
\r
int i = 0;
\r
\r
- while (i < s.length && s[i] != null) {
\r
- String seq = "";
\r
- if (gaps) {
\r
- seq = s[i].getSequence() + "*";
\r
- } else {
\r
- seq = AlignSeq.extractGaps(s[i].getSequence(),"-");
\r
- seq = AlignSeq.extractGaps(seq,".");
\r
- seq = AlignSeq.extractGaps(seq," ");
\r
- seq = seq + "*";
\r
- }
\r
+ while ( (i < s.length) && (s[i] != null))
\r
+ {
\r
+ String seq = s[i].getSequence();
\r
+ seq = seq + "*";
\r
\r
\r
- out.append(">P1;" + s[i].getName() + "/" + s[i].getStart()+ "-" + s[i].getEnd() + "\n");
\r
- out.append(" Dummy title\n");
\r
- int nochunks = seq.length() / len + 1;
\r
+ out.append(">P1;" + printId(s[i]) + "\n");
\r
\r
\r
- for (int j = 0; j < nochunks; j++) {
\r
- int start = j*len;
\r
+ if(s[i].getDescription()!=null)
\r
+ out.append(s[i].getDescription()+"\n");
\r
+ else
\r
+ {
\r
+ out.append(s[i].getName()+" "+ (s[i].getEnd() - s[i].getStart() + 1));
\r
+ out.append( is_NA ? " bases\n" : " residues\n");
\r
+ }
\r
+ int nochunks = (seq.length() / len) + 1;
\r
+
\r
+ for (int j = 0; j < nochunks; j++)
\r
+ {
\r
+ int start = j * len;
\r
int end = start + len;
\r
\r
int end = start + len;
\r
\r
- if (end < seq.length()) {
\r
- out.append(seq.substring(start,end) + "\n");
\r
- } else if (start < seq.length()) {
\r
+ if (end < seq.length())
\r
+ {
\r
+ out.append(seq.substring(start, end) + "\n");
\r
+ }
\r
+ else if (start < seq.length())
\r
+ {
\r
out.append(seq.substring(start) + "\n");
\r
}
\r
}
\r
out.append(seq.substring(start) + "\n");
\r
}
\r
}
\r
+
\r
i++;
\r
}
\r
i++;
\r
}
\r
+
\r
return out.toString();
\r
}
\r
\r
return out.toString();
\r
}
\r
\r
- public static void main(String[] args) {
\r
- String inStr = ">P1;LCAT_MOUSE_90.35\nMGLPGSPWQRVLLLLGLLLPPATPFWLLNVLFPPHTTPKAELSNHTRPVILVPGCLGNRLEAKLDKPDVVNW\nMCYRKTEDFFTIWLDFNLFLPLGVDCWIDNTRIVYNHSSGRVSNAPGVQIRVPGFGKTESVEYVDDNKLAGY\n\n>LCAT_PAPAN_95.78\nMGPPGSPWQWVPLLLGLLLPPAAPFWLLNVLFPPHTTPKAELSNHTRPVILVPGCLGNQLEAKLDKPDVVNW\nMCYRKTEDFFTIWLDLNMFLPLGVDCWIDNTRVVYNRSSGLVSNAPGVQIRVPGFGKTYSVEYLDSSKLAGY\nLHTLVQNLVNNGYVRDETVRAAPYDWRLEPGQQEEYYHKLAGLVEEMHAAYGKPVFLIGHSLGCLHLLYFLL\n";
\r
- PIRFile fa = new PIRFile(inStr);
\r
- }
\r
}
\r
}
\r
-
\r
-
\r
-
\r