Skip to content

Commit

Permalink
code refactoring for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
susiehgt committed Feb 14, 2025
1 parent 2a3efd3 commit ba04427
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class FileFormater {
private String[] header = {"Interaction Number", "Input Participant ID", "Input Participant Name",
"Experimental role", "Input Participant ID database", "Interaction detection method",
"Participant identification method", "Host organism", "Experimental preparation",
"Biological role", "Participant organism"};
"Biological role", "Participant organism", "Participant Expressed in organism",};

private final Map<String, Integer> participantCountMap = new HashMap<>();

Expand Down Expand Up @@ -342,7 +342,7 @@ public void addInteractionType() {
if (count > 2) {
row.add("association");
} else {
row.add("physical interaction");
row.add("physical association"); //todo: check with kalpana
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class ParticipantAndInteractionCreatorGui {
private final JComboBox<String> preyOrganism = new JComboBox<>();
private final JComboBox<String> preyIdDatabase = new JComboBox<>();

private final JComboBox<String> preyExpressedInOrganism = new JComboBox<>();

@Getter
private final JSpinner numberOfExperimentalPrep = new JSpinner(new SpinnerNumberModel(1, 1, 10, 1));

Expand Down Expand Up @@ -143,10 +145,12 @@ public void setOrganisms() {
baitOrganism.setEditable(true);
preyOrganism.setEditable(true);
hostOrganism.setEditable(true);
preyExpressedInOrganism.setEditable(true);
for (ParticipantOrganism participantOrganism : ParticipantOrganism.values()) {
preyOrganism.addItem(participantOrganism.name + " (" + participantOrganism.taxId + ")");
baitOrganism.addItem(participantOrganism.name + " (" + participantOrganism.taxId + ")");
hostOrganism.addItem(participantOrganism.name + " (" + participantOrganism.taxId + ")");
preyExpressedInOrganism.addItem(participantOrganism.name + " (" + participantOrganism.taxId + ")");
}
}

Expand Down Expand Up @@ -180,6 +184,7 @@ public Map<String, String> getParticipantDetails() {
participantDetails.put(DataForRawFile.PREY_ORGANISM.name,
isValueNull(XmlMakerUtils.fetchTaxIdForOrganism(Objects.requireNonNull(preyOrganism.getSelectedItem()).toString()), DataForRawFile.PREY_ORGANISM.name));
participantDetails.put(DataForRawFile.HOST_ORGANSIM.name, isValueNull(XmlMakerUtils.fetchTaxIdForOrganism(Objects.requireNonNull(hostOrganism.getSelectedItem()).toString()), DataForRawFile.HOST_ORGANSIM.name));
participantDetails.put(DataForRawFile.PREY_EXPRESSED_IN_ORGANISM.name, isValueNull(XmlMakerUtils.fetchTaxIdForOrganism(Objects.requireNonNull(preyExpressedInOrganism.getSelectedItem()).toString()), DataForRawFile.PREY_EXPRESSED_IN_ORGANISM.name));

return participantDetails;
}
Expand Down Expand Up @@ -388,6 +393,7 @@ public JPanel createPreyPanel() {
preyPanel.add(XmlMakerUtils.setComboBoxDimension(preyExperimentalPreparation, DataForRawFile.PREY_EXPERIMENTAL_PREPARATION.name));
preyPanel.add(XmlMakerUtils.setComboBoxDimension(preyBiologicalRole, DataForRawFile.PREY_BIOLOGICAL_ROLE.name));
preyPanel.add(XmlMakerUtils.setComboBoxDimension(preyOrganism, DataForRawFile.PREY_ORGANISM.name));
preyPanel.add(XmlMakerUtils.setComboBoxDimension(preyExpressedInOrganism, DataForRawFile.PREY_EXPRESSED_IN_ORGANISM.name));
preyPanel.add(XmlMakerUtils.setComboBoxDimension(preyExperimentalPreparation, DataForRawFile.PREY_EXPERIMENTAL_PREPARATION.name));

JButton createFeatureButton = new JButton("Create feature(s)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum DataForRawFile {

BAIT_ORGANISM("Bait Organism", true, false, false),
PREY_ORGANISM("Prey Organism", false, false, false),
PREY_EXPRESSED_IN_ORGANISM("Prey Expressed In Organism", false, false, false),

FEATURE_TYPE("Feature type", false, false, true),
FEATURE_START_LOCATION("Feature Start Location", false, false, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum DataTypeAndColumn {
PARTICIPANT_ID_DB("Participant ID database"),
PARTICIPANT_TYPE("Participant type"),
PARTICIPANT_ORGANISM("Participant organism"),
PARTICIPANT_EXPRESSED_IN_ORGANISM("Participant expressed in organism"),
EXPERIMENTAL_ROLE("Experimental role"),
PARTICIPANT_IDENTIFICATION_METHOD("Participant identification method"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import uk.ac.ebi.intact.psi.mi.xmlmaker.utils.FileUtils;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.io.File;
Expand Down Expand Up @@ -143,10 +144,15 @@ private XmlSource initializeSource() {
* @return the default release date as an {@link XMLGregorianCalendar}.
* @throws RuntimeException if an error occurs while creating the release date.
*/

private XMLGregorianCalendar createDefaultReleaseDate() {
try {
GregorianCalendar calendar = new GregorianCalendar();
return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
XMLGregorianCalendar xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
xmlGregorianCalendar.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
xmlGregorianCalendar.setTime(DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED);

return xmlGregorianCalendar;
} catch (DatatypeConfigurationException e) {
LOGGER.error("Error while creating default release date", e);
throw new RuntimeException(e);
Expand Down
Loading

0 comments on commit ba04427

Please sign in to comment.