Skip to content

Commit

Permalink
updated the enum AttributeType
Browse files Browse the repository at this point in the history
waterflow80 committed Dec 1, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent b20a61a commit 140f852
Showing 4 changed files with 37 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -51,7 +51,28 @@ public class SeqColExtendedDataEntity<T> {
private SeqColEntity.NamingConvention namingConvention;

public enum AttributeType {
names, sequences, md5_sequences, lengths, sorted_name_length_pairs
names("names"),
sequences("sequences"),
md5DigestsOfSequences("md5_sequences"),
lengths("lengths"),
sortedNameLengthPairs("sorted_name_length_pairs");

private String attrVal;

AttributeType(String attrVal) {
this.attrVal = attrVal;
}

/**
* Return the enum type name given the attribute val*/
public static AttributeType fromAttributeVal(String attrVal) {
for (AttributeType b : AttributeType.values()) {
if (b.attrVal.equalsIgnoreCase(attrVal)) {
return b;
}
}
throw new IllegalArgumentException("No seqcol attribute with value " + attrVal + " found");
}
}

public SeqColExtendedDataEntity<T> setAttributeType(AttributeType attributeType) {
@@ -137,7 +158,7 @@ public static SeqColExtendedDataEntity<List<String>> constructSeqColSequencesObj
public static SeqColExtendedDataEntity<List<String>> constructSeqColSequencesMd5Object(
AssemblySequenceEntity assemblySequenceEntity) throws IOException {
SeqColExtendedDataEntity<List<String>> seqColSequencesObject = new SeqColExtendedDataEntity<List<String>>().setAttributeType(
AttributeType.md5_sequences);
AttributeType.md5DigestsOfSequences);
JSONExtData<List<String>> seqColSequencesArray = new JSONStringListExtData();
List<String> sequencesList = new LinkedList<>();

@@ -159,7 +180,7 @@ public static SeqColExtendedDataEntity<List<String>> constructSeqColSortedNameLe
return null; // Names and Lengths entities are not compatible
}
SeqColExtendedDataEntity<List<String>> SeqColSortedNameLengthPairsObject = new SeqColExtendedDataEntity<List<String>>().setAttributeType(
AttributeType.sorted_name_length_pairs);
AttributeType.sortedNameLengthPairs);
JSONExtData<List<String>> seqColSortedNameLengthPairsArray = new JSONStringListExtData();

// Get the plain name-length pairs
Original file line number Diff line number Diff line change
@@ -78,10 +78,10 @@ public SeqColLevelOneEntity constructSeqColLevelOne(List<SeqColExtendedDataEntit
case sequences:
jsonLevelOne.setSequences(dataEntity.getDigest());
break;
case md5_sequences:
case md5DigestsOfSequences:
jsonLevelOne.setMd5DigestsOfSequences(dataEntity.getDigest());
break;
case sorted_name_length_pairs:
case sortedNameLengthPairs:
jsonLevelOne.setSortedNameLengthPairs(dataEntity.getDigest());
break;
}
@@ -121,7 +121,7 @@ public SeqColLevelOneEntity constructSeqColLevelOne(
sequencesExtEntity.setDigest(digestCalculator.getSha512Digest(sequencesExtData.toString()));
// Md5Sequences
SeqColExtendedDataEntity<List<String>> md5SequencesExtEntity = new SeqColExtendedDataEntity<>();
md5SequencesExtEntity.setAttributeType(SeqColExtendedDataEntity.AttributeType.md5_sequences);
md5SequencesExtEntity.setAttributeType(SeqColExtendedDataEntity.AttributeType.md5DigestsOfSequences);
md5SequencesExtEntity.setExtendedSeqColData(md5SequencesExtData);
md5SequencesExtEntity.setDigest(digestCalculator.getSha512Digest(md5SequencesExtData.toString()));
// Lengths
@@ -136,7 +136,7 @@ public SeqColLevelOneEntity constructSeqColLevelOne(
namesExtEntity.setDigest(digestCalculator.getSha512Digest(namesExtData.toString()));
//sorted-name-length-pairs
SeqColExtendedDataEntity<List<String>> sortedNameLengthPairsExtEntity = new SeqColExtendedDataEntity<>();
sortedNameLengthPairsExtEntity.setAttributeType(SeqColExtendedDataEntity.AttributeType.sorted_name_length_pairs);
sortedNameLengthPairsExtEntity.setAttributeType(SeqColExtendedDataEntity.AttributeType.sortedNameLengthPairs);
sortedNameLengthPairsExtEntity.setExtendedSeqColData(sortedNameLengthPairsData);
sortedNameLengthPairsExtEntity.setDigest(digestCalculator.getSha512Digest(sortedNameLengthPairsData.toString()));

Original file line number Diff line number Diff line change
@@ -46,10 +46,10 @@ public Optional<SeqColLevelTwoEntity> getSeqColLevelTwoByDigest(String digest) {
case sequences:
levelTwoEntity.setSequences(extendedStringTypeData.getExtendedSeqColData().getObject());
break;
case md5_sequences:
case md5DigestsOfSequences:
levelTwoEntity.setMd5DigestsOfSequences(extendedStringTypeData.getExtendedSeqColData().getObject());
break;
case sorted_name_length_pairs:
case sortedNameLengthPairs:
levelTwoEntity.setSortedNameLengthPairs(extendedStringTypeData.getExtendedSeqColData().getObject());
break;
}
@@ -79,7 +79,7 @@ private List<SeqColExtendedDataEntity<List<String>>> getStringTypeExtendedAttrib
if (!extendedMD5Sequences.isPresent()) {
throw new RuntimeException("Extended md5 sequences data with digest:" + levelOneEntity.getSeqColLevel1Object().getMd5DigestsOfSequences() + " not found");
}
extendedMD5Sequences.get().setAttributeType(SeqColExtendedDataEntity.AttributeType.md5_sequences);
extendedMD5Sequences.get().setAttributeType(SeqColExtendedDataEntity.AttributeType.md5DigestsOfSequences);

Optional<SeqColExtendedDataEntity<List<String>>> extendedNames = extendedDataService.getExtendedAttributeByDigest(levelOneEntity.getSeqColLevel1Object().getNames());
if (!extendedNames.isPresent()) {
@@ -91,7 +91,7 @@ private List<SeqColExtendedDataEntity<List<String>>> getStringTypeExtendedAttrib
if (!extendedSortedNameLengthPairs.isPresent()) {
throw new RuntimeException("Extended names data with digest: " + levelOneEntity.getSeqColLevel1Object().getNames() + " not found");
}
extendedSortedNameLengthPairs.get().setAttributeType(SeqColExtendedDataEntity.AttributeType.sorted_name_length_pairs);
extendedSortedNameLengthPairs.get().setAttributeType(SeqColExtendedDataEntity.AttributeType.sortedNameLengthPairs);

return Arrays.asList(
extendedSequences.get(),
@@ -125,10 +125,10 @@ public SeqColLevelTwoEntity constructSeqColL2(String level0Digest,
case sequences:
levelTwoEntity.setSequences(extendedStringTypeData.getExtendedSeqColData().getObject());
break;
case md5_sequences:
case md5DigestsOfSequences:
levelTwoEntity.setMd5DigestsOfSequences(extendedStringTypeData.getExtendedSeqColData().getObject());
break;
case sorted_name_length_pairs:
case sortedNameLengthPairs:
levelTwoEntity.setSortedNameLengthPairs(extendedStringTypeData.getExtendedSeqColData().getObject());
break;
}
Original file line number Diff line number Diff line change
@@ -33,8 +33,6 @@
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

@Service
@@ -372,9 +370,10 @@ public Map<String, String> constructSeqColLevelOneMap(Map<String, List<?>> seqCo
Map<String, String> seqColL1Map = new TreeMap<>();
Set<String> seqColAttributes = seqColL2Map.keySet(); // The set of the seqCol attributes ("lengths", "sequences", etc.)
for (String attribute: seqColAttributes) {
String attributeDigest = digestCalculator.getSha512Digest(
String attributeDigest;
attributeDigest= digestCalculator.getSha512Digest(
convertSeqColLevelTwoAttributeValuesToString(seqColL2Map.get(attribute),
SeqColExtendedDataEntity.AttributeType.valueOf(
SeqColExtendedDataEntity.AttributeType.fromAttributeVal(
attribute)));
seqColL1Map.put(attribute, attributeDigest);
}

0 comments on commit 140f852

Please sign in to comment.