Skip to content

Commit

Permalink
multiple features fix
Browse files Browse the repository at this point in the history
  • Loading branch information
susiehgt committed Feb 19, 2025
1 parent 8a7fc3e commit 149a9cb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ public void addInteractionType() {
* This method includes adding feature columns for each participant (bait or prey) based on available features.
*/
private void addAllFeatures() {
System.out.println("prey features: " + preyFeatures.size());
System.out.println("bait features: " + baitFeatures.size());
int numberOfColumnsToAdd = getNumberOfFeaturesColumns() * 6;
ArrayList<String> featuresHeader = getFeaturesHeader();
String[] extendedHeader = Arrays.copyOf(header, header.length + numberOfColumnsToAdd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class ParticipantAndInteractionCreatorGui {
private final JComboBox<String> baitOrganism = new JComboBox<>();
private final JComboBox<String> baitIdDatabase = new JComboBox<>();

// private final JComboBox<String> preyExperimentalPreparation = new JComboBox<>();
private final List<JComboBox<String>> preyExperimentalPreparationList = new ArrayList<>();
private final List<String> preyExperimentalPreparationNames = new ArrayList<>();

Expand Down Expand Up @@ -299,8 +298,6 @@ private void updateExperimentalPreparations(int count, JPanel experimentalPrepar
experimentalPreparationsPanel.repaint();
}



/**
* Retrieves the selected bait experimental preparations as a semicolon-separated string.
*
Expand Down Expand Up @@ -480,11 +477,11 @@ private JPanel createFeatureOptionPanel(boolean bait) {
numberOfFeature.addChangeListener(e -> {
int value = (int) numberOfFeature.getValue();
SwingUtilities.invokeLater(() -> {
if (bait){
baitFeaturesComboBoxes.clear();
} else {
preyFeaturesComboBoxes.clear();
}
// if (bait){
// baitFeaturesComboBoxes.clear();
// } else {
// preyFeaturesComboBoxes.clear();
// }
updateFeaturePanel(featureContainerPanel, value, bait);
});
});
Expand Down Expand Up @@ -512,6 +509,11 @@ private void updateFeaturePanel(JPanel featureContainerPanel, int count, boolean
}
for (int i = currentCount - 1; i >= count; i--) {
featureContainerPanel.remove(i);
if (bait){
baitFeaturesComboBoxes.remove(i);
} else {
preyFeaturesComboBoxes.remove(i);
}
}

featureContainerPanel.revalidate();
Expand Down Expand Up @@ -572,8 +574,12 @@ public List<Map<String, String>> getFeaturesData(boolean bait){
List<Map<String, String>> featuresData;
if (bait) {
featuresData = getFeaturesDataFromCombobox(baitFeaturesComboBoxes, true);
System.out.println("comboboxes: " + baitFeaturesComboBoxes.size());
System.out.println("features data:" + featuresData.size());
} else {
featuresData = getFeaturesDataFromCombobox(preyFeaturesComboBoxes, false);
System.out.println("comboboxes: " + preyFeaturesComboBoxes.size());
System.out.println("features data:" + featuresData.size());
}

return featuresData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class InteractionWriter {
@Getter @Setter
private String name;

public final List<String> skippedParticipants = new ArrayList<>();

/**
* Constructs a InteractionWriter instance with the given dependencies.
*
Expand Down Expand Up @@ -226,6 +228,7 @@ private void writeInteractionsToFile(List<XmlInteractionEvidence> interactions,
LOGGER.error("Error during PSI-XML writing", e);
} finally {
closeWriter(xmlInteractionWriter);
XmlMakerUtils.showInfoDialog("Participant skipped because of missing data: " + skippedParticipants);
XmlMakerUtils.showInfoDialog("PSI-XML writing completed successfully. File saved at: " + saveLocation);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class InteractionsCreator {
public final List<XmlInteractionEvidence> xmlModelledInteractions = new ArrayList<>();
public final List<Map<String, String>> dataList = new ArrayList<>();


@Setter
Map<String, Integer> columnAndIndex;
public String sheetSelected;
Expand Down Expand Up @@ -105,6 +106,14 @@ public XmlParticipantEvidence createParticipant(Map<String, String> data) {
for (DataTypeAndColumn requiredColumn : required) {
if (data.get(requiredColumn.name) == null || data.get(requiredColumn.name).trim().isBlank()) {
LOGGER.warning(requiredColumn.name + " is required but missing or empty.");

if (!(data.get(PARTICIPANT_NAME.name) == null) || !data.get(PARTICIPANT_NAME.name).trim().isBlank()) {
interactionWriter.skippedParticipants.add(data.get(PARTICIPANT_NAME.name));
}
else if (!(data.get(PARTICIPANT_ID.name) == null) || !data.get(PARTICIPANT_ID.name).trim().isBlank()) {
interactionWriter.skippedParticipants.add(data.get(PARTICIPANT_ID.name));
}

return null;
}
}
Expand Down Expand Up @@ -210,8 +219,6 @@ private Interactor createParticipantByType(String participantType, String name,
break;
case "gene":
participant = new XmlGene(name, organism, uniqueId);
CvTerm geneType = utils.fetchTerm("gene");
participant.setInteractorType(geneType); // needed as the type is not set automatically by jami here
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class XmlMakerUtils {
private static final Map<String, CvTerm> nameToCvTerm = new ConcurrentHashMap<>();
private static final Map<String, String> nameToTaxIdCache = new ConcurrentHashMap<>();
static final OLSClient olsClient = new OLSClient(new OLSWsConfig());

static {
try {
FileHandler fileHandler = new FileHandler("xmlmakerutils.log", true);
Expand Down

0 comments on commit 149a9cb

Please sign in to comment.