Skip to content

Commit

Permalink
Importer: Change error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
danjasuw committed Sep 5, 2018
1 parent 9acbbaa commit c0aaa49
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -171,23 +172,39 @@ private GetCrosslinkProteinMappingsSinglePeptideData getProteinMappingForSingleP
reportedPeptide // for error reporting only
);
if( proteinMap.size() < 1 ) {
String msg = null;

List<String> linkersToStringArray = new ArrayList<>( linkerList.size() );
for ( ILinker linkerItem : linkerList ) {
linkersToStringArray.add( linkerItem.toString() );
}
String linkersToString = StringUtils.join( linkersToStringArray, "," );

List<Integer> peptideLinkPositions = new ArrayList<>();
peptideLinkPositions.add( peptideCrossLinkPosition );

if ( peptideMonolinkPositions != null && ( ! peptideMonolinkPositions.isEmpty() ) ) {
msg = "Could not map this peptide and link position and monolink positions to any protein in the Proxl XML file for peptide "
+ peptide.getSequence()
+ " at crosslink position: " + peptideCrossLinkPosition
+ ", monolink position(s): " + StringUtils.join( peptideMonolinkPositions, ", " )
+ " for "
+ " linker(s). reportedPeptide sequence: " + reportedPeptide.getReportedPeptideString();
} else {
msg = "Could not map this peptide and link position to any protein in the Proxl XML file for "
+ peptide.getSequence()
+ " at crosslink position: " + peptideCrossLinkPosition
+ " for "
+ " linker(s). reportedPeptide sequence: " + reportedPeptide.getReportedPeptideString();

for ( Integer peptideMonolinkPosition : peptideMonolinkPositions ) {
if ( ! peptideLinkPositions.contains( peptideMonolinkPosition ) ) {
peptideLinkPositions.add( peptideMonolinkPosition );
}
}
}
log.error( msg );
throw new ProxlImporterDataException( "getCrosslinks(...): " + msg );

Collections.sort( peptideLinkPositions );

String msg = "Could not import this Proxl XML file. Either no protein in the Proxl XML contained this peptide sequence ("
+ peptide.getSequence()
+ ") or the linked position(s) reported for the peptide (positions "
+ StringUtils.join( peptideLinkPositions, ", " )
+ ") was not a linkable position in the matched protein for the given cross-linker(s) (["
+ linkersToString
+ "]). The whole reported peptide string was: "
+ reportedPeptide.getReportedPeptideString()
+ "\n\nThis is most-probably caused by specifying the incorrect cross-linker or the incorrect FASTA file when generating the Proxl XML file.";

log.error( "getCrosslinks(...): Msg thrown in ProxlImporterDataException: " + msg );
throw new ProxlImporterDataException( msg );
}
/// Data in perPeptideData for Monolinks
List<MonolinkContainer> monolinkContainerList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,32 @@ private GetDimerProteinMappingsSinglePeptideData getProteinMappingForSinglePepti
);
if( proteinMap.size() < 1 ) {
String msg = null;

if ( peptideMonolinkPositions != null && ( ! peptideMonolinkPositions.isEmpty() ) ) {
msg = "Could not map this peptide and monolink positions to any protein in the Proxl XML file for peptide "
+ peptide.getSequence()
+ ", monolink position(s): " + StringUtils.join( peptideMonolinkPositions, ", " )
+ " for "
+ " linker(s). reportedPeptide sequence: " + reportedPeptide.getReportedPeptideString();

List<String> linkersToStringArray = new ArrayList<>( linkerList.size() );
for ( ILinker linkerItem : linkerList ) {
linkersToStringArray.add( linkerItem.toString() );
}
String linkersToString = StringUtils.join( linkersToStringArray, "," );

msg = "Could not import this Proxl XML file. Either no protein in the Proxl XML contained this peptide sequence ("
+ peptide.getSequence()
+ ") or the linked position(s) reported for the peptide (positions "
+ StringUtils.join( peptideMonolinkPositions, ", " )
+ ") was not a linkable position in the matched protein for the given cross-linker(s) (["
+ linkersToString
+ "]). The whole reported peptide string was: "
+ reportedPeptide.getReportedPeptideString()
+ " \n\nThis is most-probably caused by specifying the incorrect cross-linker or the incorrect FASTA file when generating the Proxl XML file.";
} else {
msg = "Could not map this peptide to any protein in the Proxl XML file for "
+ peptide.getSequence()
+ ". reportedPeptide sequence: " + reportedPeptide.getReportedPeptideString();
msg = "Could not import this Proxl XML file. No protein in the Proxl XML contained this peptide sequence ("
+ peptide.getSequence()
+ "). The whole reported peptide string was: "
+ reportedPeptide.getReportedPeptideString()
+ " \n\nThis is most-probably caused by specifying the incorrect FASTA file when generating the Proxl XML file.";
}
log.error( "getProteinMappingForSinglePeptide(...): " + msg );
log.error( "getProteinMappingForSinglePeptide(...): Msg thrown in ProxlImporterDataException: " + msg );
throw new ProxlImporterDataException( msg );
}
/// Data in perPeptideData for Monolinks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -136,22 +137,39 @@ public GetLooplinkProteinMappingsResult getLooplinkroteinMappings(
reportedPeptide // For error reporting only
);
if( proteinMap.size() < 1 ) {
String msg = null;

List<String> linkersToStringArray = new ArrayList<>( linkerList.size() );
for ( ILinker linkerItem : linkerList ) {
linkersToStringArray.add( linkerItem.toString() );
}
String linkersToString = StringUtils.join( linkersToStringArray, "," );

List<Integer> peptideLinkPositions = new ArrayList<>();
peptideLinkPositions.add( peptideLinkedPosition_1 );
peptideLinkPositions.add( peptideLinkedPosition_2 );

if ( peptideMonolinkPositions != null && ( ! peptideMonolinkPositions.isEmpty() ) ) {
msg = "Could not map this peptide and link position and monolink positions to any protein in the Proxl XML file for peptide "
+ peptide.getSequence()
+ " at looplink positions: " + peptideLinkedPosition_1 + "," + peptideLinkedPosition_2
+ ", monolink position(s): " + StringUtils.join( peptideMonolinkPositions, ", " )
+ " for "
+ " linker(s). reportedPeptide sequence: " + reportedPeptide.getReportedPeptideString();
} else {
msg = "Could not map this peptide and link position to any protein in the Proxl XML file for "
+ peptide.getSequence()
+ " at looplink positions: " + peptideLinkedPosition_1 + "," + peptideLinkedPosition_2
+ " for "
+ " linker(s). reportedPeptide sequence: " + reportedPeptide.getReportedPeptideString();

for ( Integer peptideMonolinkPosition : peptideMonolinkPositions ) {
if ( ! peptideLinkPositions.contains( peptideMonolinkPosition ) ) {
peptideLinkPositions.add( peptideMonolinkPosition );
}
}
}
log.error( "getLooplinks(...): " + msg );

Collections.sort( peptideLinkPositions );

String msg = "Could not import this Proxl XML file. Either no protein in the Proxl XML contained this peptide sequence ("
+ peptide.getSequence()
+ ") or the linked position(s) reported for the peptide (positions "
+ StringUtils.join( peptideLinkPositions, ", " )
+ ") was not a linkable position in the matched protein for the given cross-linker(s) (["
+ linkersToString
+ "]). The whole reported peptide string was: "
+ reportedPeptide.getReportedPeptideString()
+ " \n\nThis is most-probably caused by specifying the incorrect cross-linker or the incorrect FASTA file when generating the Proxl XML file.";

log.error( "getLooplinks(...): Msg thrown in ProxlImporterDataException: " + msg );
throw new ProxlImporterDataException( msg );
}
/// Data in perPeptideData for Monolinks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,30 @@ public GetUnlinkedProteinMappingsResult getUnlinkedroteinMappings(
if( proteinMap.size() < 1 ) {
String msg = null;
if ( peptideMonolinkPositions != null && ( ! peptideMonolinkPositions.isEmpty() ) ) {
msg = "Could not map this peptide and monolink positions to any protein in the Proxl XML file for peptide "
+ peptide.getSequence()
+ ", monolink position(s): " + StringUtils.join( peptideMonolinkPositions, ", " )
+ " for "
+ " linker(s). reportedPeptide sequence: " + reportedPeptide.getReportedPeptideString();

List<String> linkersToStringArray = new ArrayList<>( linkerList.size() );
for ( ILinker linkerItem : linkerList ) {
linkersToStringArray.add( linkerItem.toString() );
}
String linkersToString = StringUtils.join( linkersToStringArray, "," );

msg = "Could not import this Proxl XML file. Either no protein in the Proxl XML contained this peptide sequence ("
+ peptide.getSequence()
+ ") or the linked position(s) reported for the peptide (positions "
+ StringUtils.join( peptideMonolinkPositions, ", " )
+ ") was not a linkable position in the matched protein for the given cross-linker(s) (["
+ linkersToString
+ "]). The whole reported peptide string was: "
+ reportedPeptide.getReportedPeptideString()
+ " \n\nThis is most-probably caused by specifying the incorrect cross-linker or the incorrect FASTA file when generating the Proxl XML file.";
} else {
msg = "Could not map this peptide to any protein in the Proxl XML file for "
+ peptide.getSequence()
+ ". reportedPeptide sequence: " + reportedPeptide.getReportedPeptideString();
msg = "Could not import this Proxl XML file. No protein in the Proxl XML contained this peptide sequence ("
+ peptide.getSequence()
+ "). The whole reported peptide string was: "
+ reportedPeptide.getReportedPeptideString()
+ " \n\nThis is most-probably caused by specifying the incorrect FASTA file when generating the Proxl XML file.";
}
log.error( "getUnlinkedroteinMappings(...): " + msg );
log.error( "getUnlinkedroteinMappings(...): Msg thrown in ProxlImporterDataException: " + msg );
throw new ProxlImporterDataException( msg );
}
/// Data in perPeptideData for Monolinks
Expand Down

0 comments on commit c0aaa49

Please sign in to comment.