Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion flow/src/org/labkey/flow/ScriptParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.xmlbeans.XmlOptions;
import org.fhcrc.cpas.flow.script.xml.ScriptDef;
import org.fhcrc.cpas.flow.script.xml.ScriptDocument;
import org.labkey.api.util.StringUtilsLabKey;
import org.xml.sax.SAXParseException;

import java.io.StringReader;
Expand Down Expand Up @@ -94,7 +95,7 @@ public void parse(String script)
message = StringUtils.replace(message, "@" + ScriptDocument.type.getContentModel().getName().getNamespaceURI(), "");
String location = xmlError.getCursorLocation().xmlText();
if (location.length() > 100)
location = location.substring(0, 100);
location = StringUtilsLabKey.leftSurrogatePairFriendly(location, 100);
addError(new Error("Schema Validation Error: " + message + "\nLocation of invalid XML: " + location));
}
}
Expand Down
3 changes: 2 additions & 1 deletion protein/api-src/org/labkey/api/protein/ProteinManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.labkey.api.util.HashHelpers;
import org.labkey.api.util.HtmlString;
import org.labkey.api.util.LinkBuilder;
import org.labkey.api.util.StringUtilsLabKey;
import org.labkey.api.view.NotFoundException;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -100,7 +101,7 @@ private static SimpleProtein ensureProteinInDatabase(String sequence, Organism o
map.put("Mass", PeptideHelpers.computeMass(sequenceBytes, 0, sequenceBytes.length, PeptideHelpers.AMINO_ACID_AVERAGE_MASSES));
map.put("OrgId", organism.getOrgId());
map.put("Hash", hashSequence(sequence));
map.put("Description", description == null ? null : (description.length() > 200 ? description.substring(0, 196) + "..." : description));
map.put("Description", description == null ? null : (description.length() > 200 ? StringUtilsLabKey.leftSurrogatePairFriendly(description, 196) + "..." : description));
map.put("BestName", name);
map.put("Length", sequence.length());
map.put("InsertDate", new Date());
Expand Down
3 changes: 2 additions & 1 deletion protein/api-src/org/labkey/api/protein/ProteinPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.labkey.api.protein.fasta.FastaProtein;
import org.labkey.api.util.HashHelpers;
import org.labkey.api.util.StringUtilsLabKey;

public class ProteinPlus
{
Expand Down Expand Up @@ -111,7 +112,7 @@ public String getBestName()
{
result = getProtein().getHeader();
}
if (result.length() > 500) result = result.substring(0, 499);
if (result.length() > 500) result = StringUtilsLabKey.leftSurrogatePairFriendly(result, 499);
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.labkey.api.protein.organism.OrganismGuessStrategy;
import org.labkey.api.util.HashHelpers;
import org.labkey.api.util.NetworkDrive;
import org.labkey.api.util.StringUtilsLabKey;
import org.labkey.api.view.ViewBackgroundInfo;

import java.io.File;
Expand Down Expand Up @@ -259,7 +260,7 @@ protected void preProcessSequences(List<ProteinPlus> mouthful, Connection c, Log
}
else
{
if (desc.length() >= 200) desc = desc.substring(0, 195) + "...";
if (desc.length() >= 200) desc = StringUtilsLabKey.leftSurrogatePairFriendly(desc, 195) + "...";
fdbu._addSeqStmt.setString(3, desc);
}
fdbu._addSeqStmt.setDouble(4, curSeq.getProtein().getMass());
Expand Down
3 changes: 2 additions & 1 deletion protein/api-src/org/labkey/api/protein/fasta/IdPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.labkey.api.util.StringUtilsLabKey;

/**
* this class implements a regular expression-based recognition of identifiers parsed from the fasta files.
Expand Down Expand Up @@ -178,7 +179,7 @@ public static Map<String, Set<String>> createIdMap(String key, String value)
{
v = v.trim();
if (v.length() > 50)
v = v.substring(0, 50);
v = StringUtilsLabKey.leftSurrogatePairFriendly(v, 50);
if (!v.isEmpty())
vals.add(v);
}
Expand Down
8 changes: 4 additions & 4 deletions protein/api-src/org/labkey/api/protein/uniprot/uniprot.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ public int insertSequences(ParseContext context, Connection conn) throws SQLExce
else
{
String tmp = curSeq.getDescription();
if (tmp.length() >= 200) tmp = tmp.substring(0, 190) + "...";
if (tmp.length() >= 200) tmp = StringUtilsLabKey.leftSurrogatePairFriendly(tmp, 190) + "...";
_addSeq.setString(3, tmp);
}
if (curSeq.getSourceChangeDate() == null)
Expand Down Expand Up @@ -657,7 +657,7 @@ public int insertSequences(ParseContext context, Connection conn) throws SQLExce
else
{
String tmp = curSeq.getBestName();
if (tmp.length() >= 50) tmp = tmp.substring(0, 45) + "...";
if (tmp.length() >= 50) tmp = StringUtilsLabKey.leftSurrogatePairFriendly(tmp, 45) + "...";
_addSeq.setString(11, tmp);
}
if (curSeq.getBestGeneName() == null)
Expand All @@ -667,7 +667,7 @@ public int insertSequences(ParseContext context, Connection conn) throws SQLExce
else
{
String tmp = curSeq.getBestGeneName();
if (tmp.length() >= 50) tmp = tmp.substring(0, 45) + "...";
if (tmp.length() >= 50) tmp = StringUtilsLabKey.leftSurrogatePairFriendly(tmp, 45) + "...";
_addSeq.setString(12, tmp);
}
// Timestamp at index 13 is set once for the whole prepared statement
Expand Down Expand Up @@ -709,7 +709,7 @@ public int insertIdentifiers(ParseContext context, Connection conn) throws SQLEx
{
transactionCount++;
String curIdentVal = curIdent.getIdentifier();
if (curIdentVal.length() > 50) curIdentVal = curIdentVal.substring(0, 45) + "...";
if (curIdentVal.length() > 50) curIdentVal = StringUtilsLabKey.leftSurrogatePairFriendly(curIdentVal, 45) + "...";
_addIdent.setString(1, curIdentVal);
_addIdent.setString(2, curIdent.getIdentType());
UniprotSequence curSeq = curIdent.getSequence();
Expand Down
Loading