public static final String PAIRPROFILE = "B";
- public static final Hashtable[] calculate(Vector sequences, int start,
- int end)
- {
- return calculate(sequences, start, end, false);
- }
-
- public static final Hashtable[] calculate(Vector sequences, int start,
- int end, boolean profile)
- {
- SequenceI[] seqs = new SequenceI[sequences.size()];
- int width = 0;
- for (int i = 0; i < sequences.size(); i++)
- {
- seqs[i] = (SequenceI) sequences.elementAt(i);
- if (seqs[i].getLength() > width)
- {
- width = seqs[i].getLength();
- }
- }
-
- Hashtable[] reply = new Hashtable[width];
-
- if (end >= width)
- {
- end = width;
- }
-
- calculate(seqs, start, end, reply, profile);
-
- return reply;
- }
-
- public static final void calculate(SequenceI[] sequences, int start,
- int end, Hashtable[] result)
- {
- calculate(sequences, start, end, result, false);
- }
-
- public static final void calculate(SequenceI[] sequences, int start,
- int end, Hashtable[] result, boolean profile)
- {
- Hashtable residueHash;
- int maxCount, nongap, i, j, v, jSize = sequences.length;
- String maxResidue;
- char c;
- float percentage;
-
- int[] values = new int[255];
-
- char[] seq;
-
- for (i = start; i < end; i++)
- {
- residueHash = new Hashtable();
- maxCount = 0;
- maxResidue = "";
- nongap = 0;
- values = new int[255];
-
- for (j = 0; j < jSize; j++)
- {
- if (sequences[j] == null)
- {
- System.err
- .println("WARNING: Consensus skipping null sequence - possible race condition.");
- continue;
- }
- seq = sequences[j].getSequence();
- if (seq.length > i)
- {
- c = seq[i];
-
- if (c == '.' || c == ' ')
- {
- c = '-';
- }
-
- if (c == '-')
- {
- values['-']++;
- continue;
- }
- else if ('a' <= c && c <= 'z')
- {
- c -= 32; // ('a' - 'A');
- }
-
- nongap++;
- values[c]++;
-
- }
- else
- {
- values['-']++;
- }
- }
-
- for (v = 'A'; v < 'Z'; v++)
- {
- if (values[v] < 2 || values[v] < maxCount)
- {
- continue;
- }
-
- if (values[v] > maxCount)
- {
- maxResidue = String.valueOf((char) v);
- }
- else if (values[v] == maxCount)
- {
- maxResidue += String.valueOf((char) v);
- }
- maxCount = values[v];
- }
-
- if (maxResidue.length() == 0)
- {
- maxResidue = "-";
- }
- if (profile)
- {
- residueHash.put(PROFILE, new int[][]
- { values, new int[]
- { jSize, nongap } });
- }
- residueHash.put(MAXCOUNT, new Integer(maxCount));
- residueHash.put(MAXRESIDUE, maxResidue);
-
- percentage = ((float) maxCount * 100) / (float) jSize;
- residueHash.put(PID_GAPS, new Float(percentage));
-
- percentage = ((float) maxCount * 100) / (float) nongap;
- residueHash.put(PID_NOGAPS, new Float(percentage));
- result[i] = residueHash;
- }
- }
-
+/**
+ * Returns the 3' position of a base pair
+ * @param pairs Secondary structure annotation
+ * @param indice 5' position of a base pair
+ * @return 3' position of a base pair
+ */
public static int findPair(SequenceFeature[] pairs, int indice)
{
for (int i = 0; i < pairs.length; i++)
int end, Hashtable[] result, boolean profile,
AlignmentAnnotation rnaStruc)
{
- // System.out.println("StructureFrequency.calculateNEW4");
Hashtable residueHash;
String maxResidue;
char[] seq, struc = rnaStruc.getRNAStruc().toCharArray();
{
values['H']++; // H means it's a helix (structured)
}
- // System.out.println("pair: "+c+","+cEnd);
pairs[c][cEnd]++;
- // System.out.println("pairs: "+c+","+cEnd+" - "+pairs[c][cEnd]);
maxResidue = "H";
}
// UPDATE this for new values
if (profile)
{
- // System.out.println("profile");
residueHash.put(PROFILE, new int[][]
{ values, new int[]
{ jSize, (jSize - values['-']) } });
boolean ignoreGapsInConsensusCalculation,
boolean includeAllConsSymbols, char[] alphabet)
{
- System.out.println("StructureFrequency.completeConsensus "
- + includeAllConsSymbols);
float tval, value;
if (consensus == null || consensus.annotations == null
|| consensus.annotations.length < width)
if (profile != null && includeAllConsSymbols) // Just responsible for the
// tooltip
{
- // System.out.println("StructureFrequency.includeAllConsSymbols");
mouseOver = "";
if (alphabet != null)
{
}
else
{
- // System.out.println("StructureFrequency.NOTincludeAllConsSymbols");
Object[] ca = new Object[profile[0].length];
float[] vl = new float[profile[0].length];
for (int c = 0; c < ca.length; c++)
}
/**
- * get the sorted profile for the given position of the consensus
+ * get the sorted base-pair profile for the given position of the consensus
*
* @param hconsensus
- * @return
+ * @return profile of the given column
*/
public static int[] extractProfile(Hashtable hconsensus,
boolean ignoreGapsInConsensusCalculation, int column)
consensus.hasText = true;
consensus.autoCalculated = true;
- // TODO check if this can done accordingly
- strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
- new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
- strucConsensus.hasText = true;
- strucConsensus.autoCalculated = true;
-
+ if (alignment.isNucleotide())
+ {
+ strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
+ new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
+ strucConsensus.hasText = true;
+ strucConsensus.autoCalculated = true;
+ }
+
if (Cache.getDefault("SHOW_IDENTITY", true))
{
alignment.addAnnotation(consensus);
// TODO: Make own if for structure
- alignment.addAnnotation(strucConsensus);
+ if (alignment.isNucleotide())
+ {
+ alignment.addAnnotation(strucConsensus);
+ }
}
}