Newer
Older
if(gcode_default != null)
{
if(defS.length() < 3)
{
try
{
int num = Integer.parseInt(defS);
if(num > 0 && num <= gcodes.length)
default_code = num-1;
else
System.err.println(defS+" is not a valid number");
}
catch(NumberFormatException nfe)
{
System.err.println(defS+" is not a valid number");
}
}
}
geneCode = new JCheckBoxMenuItem[gcodes.length];
if(gcodes[i].equals("-"))
continue;
int ind1;
while((ind1 = gcodes[i].indexOf("_")) > -1)
gcodes[i] = gcodes[i].substring(0,ind1) + " " +
gcodes[i].substring(ind1+1,gcodes[i].length());
String num = Integer.toString(i+1);
final String gc_name = num+". "+gcodes[i];
geneCode[i] = new JCheckBoxMenuItem(gc_name);
gcodeGroup.add(geneCode[i]);
final int menuNum = i;
geneCode[i].setActionCommand(num);
geneCode[i].addItemListener(new ItemListener()
if(geneCode[menuNum].getState())
String tab = "translation_table_"+geneCode[menuNum].getActionCommand();
String startCodons = "start_codons_"+geneCode[menuNum].getActionCommand();
StringVector options_file_table =
Options.getOptions().getOptionValues(tab);
if(options_file_table != null)
{
if(options_file_table.size() == 64)
{
StringBuffer sbuff = new StringBuffer();
for(int i = 0; i < 64; ++i)
sbuff.append(options_file_table.elementAt(i)+" ");
Options.getOptions().setGeneticCode(sbuff.toString());
}
else
{
StringVector table = Options.getOptions().getOptionValues("translation_table_1");
for(int i = 0; i < options_file_table.size(); ++i)
{
String cod_plus_aa = (String)options_file_table.elementAt(i);
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
// System.out.println(cod_plus_aa);
final int codon_index = Bases.getIndexOfBase(cod_plus_aa.charAt(0)) * 16 +
Bases.getIndexOfBase(cod_plus_aa.charAt(1)) * 4 +
Bases.getIndexOfBase(cod_plus_aa.charAt(2));
// System.out.println(cod_plus_aa.substring(3)+" "+codon_index+" "+
// table.elementAt(codon_index));
table.setElementAt(cod_plus_aa.substring(3), codon_index);
}
StringBuffer sbuff = new StringBuffer();
for(int i = 0; i < 64; ++i)
sbuff.append(table.elementAt(i)+" ");
Options.getOptions().setGeneticCode(sbuff.toString());
}
options_file_table =
Options.getOptions().getOptionValues(startCodons);
if(options_file_table != null)
{
StringBuffer sbuff = new StringBuffer();
for(int i = 0; i < options_file_table.size(); ++i)
sbuff.append(options_file_table.elementAt(i)+" ");
Options.getOptions().setProperty("start_codons",sbuff.toString());
}
}
AminoAcidSequence.setGeneCode();
if(helix_canvas != null)
helix_canvas.repaint();
}
}
});
options_menu.add(geneCode[i]);
if(i == default_code)
geneCode[i].setState(true);
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
/**
* Set the Genetic Code number
* @param geneticCodeValue
*/
public void setTranslationTable(final String geneticCodeValue)
{
for(int i=0;i<geneCode.length;i++)
{
if(geneCode[i] == null)
continue;
if( geneCode[i].getActionCommand().equals(geneticCodeValue) &&
!geneCode[i].getState() )
{
int val = JOptionPane.showConfirmDialog(null,
"Change translation table to:\n"+
geneCode[i].getText(),
"Confirm Translation Table Change",
JOptionPane.OK_CANCEL_OPTION);
if(val == JOptionPane.CANCEL_OPTION)
return;
logger4j.debug("SET GENETIC CODE translationTable="
+ geneticCodeValue);
geneCode[i].setState(true);
break;
}
}
}
/**
* Make a new menu item in the given menu, with its label given the
* String and add the given ActionListener to it.
*/
protected static void makeMenuItem(JMenu menu, String name,
ActionListener listener)
{
JMenuItem new_item = new JMenuItem(name);
menu.add(new_item);
new_item.addActionListener(listener);
if(name.equals("Open ..."))
new_item.setAccelerator(KeyStroke.getKeyStroke
(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); // InputEvent.CTRL_MASK));
}
/**
* Return a Logger for warnings/errors/messages.
**/
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
{
return logger;
}
/**
* Return the JComponent that the Splash screen is drawing on.
**/
public JComponent getCanvas()
{
return helix_canvas;
}
/**
* Make the LogViewer visible.
**/
public static void showLog()
{
logger.setVisible(true);
}
/**
* An InputStreamProgressListener used to update the error label with the
* current number of chars read.
**/
private final InputStreamProgressListener stream_progress_listener =
new InputStreamProgressListener() {
public void progressMade(final InputStreamProgressEvent event)
{
final int char_count = event.getCharCount();
if(char_count == -1)
getStatusLabel().setText("");
else
getStatusLabel().setText("chars read so far: " + char_count);
}
public void progressMade(String progress)
{
getStatusLabel().setText(progress);
}