X Tutup
Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public TranscriptSequence(GeneSequence parentDNASequence, AccessionID accessionI
setAccession(accessionID);
}

@Override
@Override
public int getLength() {
return Math.abs(this.getBioEnd() - this.getBioBegin()) + 1;
}
Expand Down Expand Up @@ -158,40 +158,7 @@ public ArrayList<ProteinSequence> getProteinCDSSequences() {
CDSSequence cdsSequence = cdsSequenceList.get(i);
String codingSequence = cdsSequence.getCodingSequence();
// logger.debug("CDS {} {} = {}", getStrand(), cdsSequence.getPhase(), codingSequence);
if (this.getStrand() == Strand.NEGATIVE) {
if (cdsSequence.phase == 1) {
codingSequence = codingSequence.substring(1, codingSequence.length());
} else if (cdsSequence.phase == 2) {
codingSequence = codingSequence.substring(2, codingSequence.length());
}
if (i < cdsSequenceList.size() - 1) {
CDSSequence nextCDSSequence = cdsSequenceList.get(i + 1);
if (nextCDSSequence.phase == 1) {
String nextCodingSequence = nextCDSSequence.getCodingSequence();
codingSequence = codingSequence + nextCodingSequence.substring(0, 1);
} else if (nextCDSSequence.phase == 2) {
String nextCodingSequence = nextCDSSequence.getCodingSequence();
codingSequence = codingSequence + nextCodingSequence.substring(0, 2);
}
}
} else {
if (cdsSequence.phase == 1) {
codingSequence = codingSequence.substring(1, codingSequence.length());
} else if (cdsSequence.phase == 2) {
codingSequence = codingSequence.substring(2, codingSequence.length());
}
if (i < cdsSequenceList.size() - 1) {
CDSSequence nextCDSSequence = cdsSequenceList.get(i + 1);
if (nextCDSSequence.phase == 1) {
String nextCodingSequence = nextCDSSequence.getCodingSequence();
codingSequence = codingSequence + nextCodingSequence.substring(0, 1);
} else if (nextCDSSequence.phase == 2) {
String nextCodingSequence = nextCDSSequence.getCodingSequence();
codingSequence = codingSequence + nextCodingSequence.substring(0, 2);
}
}
}

codingSequence = getCodingSequence(proteinSequenceList, codingSequence, i);

// logger.debug("Coding Sequence: {}", codingSequence);

Expand All @@ -211,6 +178,31 @@ public ArrayList<ProteinSequence> getProteinCDSSequences() {
return proteinSequenceList;
}

/**
* Helper method to reduce duplication and complexity in the getProteinCDSSequences method
*
* @return string
*/
private String getCodingSequence(ArrayList<ProteinSequence> proteinSequenceList, String codingSequence, int index) {
CDSSequence cdsSequence = cdsSequenceList.get(index);
if (cdsSequence.phase == 1) {
codingSequence = codingSequence.substring(1, codingSequence.length());
} else if (cdsSequence.phase == 2) {
codingSequence = codingSequence.substring(2, codingSequence.length());
}
if (index < cdsSequenceList.size() - 1) {
CDSSequence nextCDSSequence = cdsSequenceList.get(index + 1);
if (nextCDSSequence.phase == 1) {
String nextCodingSequence = nextCDSSequence.getCodingSequence();
codingSequence = codingSequence + nextCodingSequence.substring(0, 1);
} else if (nextCDSSequence.phase == 2) {
String nextCodingSequence = nextCDSSequence.getCodingSequence();
codingSequence = codingSequence + nextCodingSequence.substring(0, 2);
}
}
return codingSequence;
}

/**
* Get the stitched together CDS sequences then maps to the cDNA
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,34 @@ public int getLength(int positionA, int positionB, String startingChain) {
int count = 0;
// Inefficient search
for (Map.Entry<ResidueNumber, Integer> entry : treeMap.entrySet()) {
if (entry.getKey().getChainName().equals(startingChain)
&& positionStart <= entry.getValue()
&& entry.getValue() <= positionEnd)
{
if (equalToStartingChain(entry,startingChain) && inRange(entry,positionStart,positionEnd)){
count++;
}
}
return count;
}

/**
* Checks if the entry is equal to the starting chain
* @param entry Map of residue number
* @param startingChain Case-sensitive chain
* @return True if the entry is equal to the starting chain
*/
private boolean equalToStartingChain(Map.Entry<ResidueNumber, Integer> entry, String startingChain){
return entry.getKey().getChainName().equals(startingChain);
}

/**
* Checks if the entry is in a specific range
* @param entry Map of residue number
* @param positionStart index of the start position
* @param positionEnd index of the end position
* @return True if the entry is in the range
*/
private boolean inRange(Map.Entry<ResidueNumber, Integer> entry, int positionStart, int positionEnd){
return positionStart <= entry.getValue() && entry.getValue() <= positionEnd;
}


/**
* Calculates the number of residues of the specified chain in a given range.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentImpl;
import org.biojava.nbio.structure.align.multiple.util.MultipleAlignmentScorer;
import org.biojava.nbio.structure.align.multiple.util.ReferenceSuperimposer;
import org.biojava.nbio.structure.cluster.Subunit;
import org.biojava.nbio.structure.cluster.SubunitCluster;
import org.biojava.nbio.structure.cluster.SubunitClusterer;
import org.biojava.nbio.structure.cluster.SubunitClustererParameters;
import org.biojava.nbio.structure.cluster.SubunitExtractor;
import org.biojava.nbio.structure.cluster.*;
import org.biojava.nbio.structure.contact.Pair;
import org.biojava.nbio.structure.geometry.SuperPositions;
import org.biojava.nbio.structure.geometry.UnitQuaternions;
Expand Down Expand Up @@ -104,7 +100,8 @@ public static QsAlignResult align(List<Subunit> s1, List<Subunit> s2,
continue;

// Use structural alignment to match the subunit clusters
if (c1.get(i).mergeStructure(c2.get(j),cParams)) {
SubunitClusterMerge subunitClusterMerge = new SubunitClusterMerge(c1.get(i));
if (subunitClusterMerge.mergeStructure(c2.get(j),cParams)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion it was more readable before, as you could see the i/j merging in a single line. Would you have a strong reason for this change?

clusterMap.put(i, j);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package org.biojava.nbio.structure.align.xml;

import org.biojava.nbio.structure.align.client.PdbPair;
import org.biojava.nbio.structure.align.fatcat.FatCatRigid;

import java.io.StringWriter;
import java.util.SortedSet;
Expand All @@ -38,7 +39,7 @@ public class PdbPairsMessage {

public PdbPairsMessage(){

method = PdbPairXMLConverter.DEFAULT_METHOD_NAME;
method = FatCatRigid.algorithmName;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was intended to point to DEFAULT_METHOD_NAME. Then there's a constant that's specific for the default.


pairs = new TreeSet<PdbPair>();

Expand Down
Loading
X Tutup