Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.io

File PileUpfile.java

 

Coverage histogram

../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

26
60
4
1
193
117
20
0.33
15
4
5

Classes

Class Line # Actions
PileUpfile 43 60 20 7
0.922222292.2%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.io;
22   
23    /**
24    * <p>
25    * Title:
26    * </p>
27    * PileUpfile
28    * <p>
29    * Description:
30    * </p>
31    *
32    * Read and write PileUp style MSF Files. This used to be the MSFFile class, and
33    * was written according to the EBI's idea of a subset of the MSF alignment
34    * format. But, that was updated to reflect current GCG style IO fashion, as
35    * found in Emboss (thanks David Martin!)
36    *
37    */
38    import jalview.datamodel.SequenceI;
39    import jalview.util.Format;
40   
41    import java.io.IOException;
42   
 
43    public class PileUpfile extends MSFfile
44    {
45   
46    /**
47    * Creates a new MSFfile object.
48    */
 
49  1 toggle public PileUpfile()
50    {
51    }
52   
53    /**
54    * Creates a new MSFfile object.
55    *
56    * @param inFile
57    * DOCUMENT ME!
58    * @param sourceType
59    * DOCUMENT ME!
60    *
61    * @throws IOException
62    * DOCUMENT ME!
63    */
 
64  0 toggle public PileUpfile(String inFile, DataSourceType sourceType)
65    throws IOException
66    {
67  0 super(inFile, sourceType);
68    }
69   
 
70  1 toggle public PileUpfile(FileParse source) throws IOException
71    {
72  1 super(source);
73    }
74   
 
75  1 toggle @Override
76    public String print(SequenceI[] s, boolean jvsuffix)
77    {
78  1 StringBuffer out = new StringBuffer("PileUp");
79  1 out.append(newline);
80  1 out.append(newline);
81   
82  1 int max = 0;
83  1 int maxid = 0;
84   
85  1 int i = 0;
86  1 int bigChecksum = 0;
87  1 int[] checksums = new int[s.length];
88  16 while (i < s.length)
89    {
90  15 checksums[i] = checkSum(s[i].getSequenceAsString());
91  15 bigChecksum += checksums[i];
92  15 i++;
93    }
94   
95  1 out.append(" MSF: " + s[0].getLength()
96    + " Type: P Check: " + bigChecksum % 10000 + " ..");
97  1 out.append(newline);
98  1 out.append(newline);
99  1 out.append(newline);
100   
101  1 i = 0;
102  16 while ((i < s.length) && (s[i] != null))
103    {
104  15 String seq = s[i].getSequenceAsString();
105  15 out.append(" Name: " + printId(s[i], jvsuffix) + " oo Len: "
106    + seq.length() + " Check: " + checksums[i]
107    + " Weight: 1.00");
108  15 out.append(newline);
109   
110  15 if (seq.length() > max)
111    {
112  1 max = seq.length();
113    }
114   
115  15 if (s[i].getName().length() > maxid)
116    {
117  3 maxid = s[i].getName().length();
118    }
119   
120  15 i++;
121    }
122   
123  1 if (maxid < 10)
124    {
125  0 maxid = 10;
126    }
127   
128  1 maxid++;
129  1 out.append(newline);
130  1 out.append(newline);
131  1 out.append("//");
132  1 out.append(newline);
133  1 out.append(newline);
134   
135  1 int len = 50;
136   
137  1 int nochunks = (max / len) + (max % len > 0 ? 1 : 0);
138   
139  5 for (i = 0; i < nochunks; i++)
140    {
141  4 int j = 0;
142   
143  64 while ((j < s.length) && (s[j] != null))
144    {
145  60 String name = printId(s[j], jvsuffix);
146   
147  60 out.append(new Format("%-" + maxid + "s").form(name + " "));
148   
149  360 for (int k = 0; k < 5; k++)
150    {
151  300 int start = (i * 50) + (k * 10);
152  300 int end = start + 10;
153   
154  300 int length = s[j].getLength();
155  300 if ((end < length) && (start < length))
156    {
157  225 out.append(s[j].getSequence(start, end));
158   
159  225 if (k < 4)
160    {
161  180 out.append(" ");
162    }
163    else
164    {
165  45 out.append(newline);
166    }
167    }
168    else
169    {
170  75 if (start < length)
171    {
172  15 out.append(s[j].getSequenceAsString().substring(start));
173  15 out.append(newline);
174    }
175    else
176    {
177  60 if (k == 0)
178    {
179  0 out.append(newline);
180    }
181    }
182    }
183    }
184   
185  60 j++;
186    }
187   
188  4 out.append(newline);
189    }
190   
191  1 return out.toString();
192    }
193    }