Skip to content

Commit

Permalink
Merge branch 'master' of github.com:biojava/biojava
Browse files Browse the repository at this point in the history
* 'master' of github.com:biojava/biojava: (211 commits)
  TestSuperPosition now tests rmsd of non-centered points.
  Documentation and minor fix
  Redo the PR #576 re-use code into a method
  Fix bug in centroid calculation SuperPositionSVD #588
  Simple integration test for superposition methods
  More complete test
  Inserts space when altLoc is null, so that the rest of fields are properly aligned.
  FileConvert fix - added empty space if altLoc is null.
  Fixing hard biounits test. Small fix in Chain docs.
  Cleanup whitespace
  Solving a compilation problem, making Grid usable for Point3d #545
  Some more work towards #545, some cleanup
  Issue #582 and some more work towards #545
  Add constructors for the MMTFFilereader
  Added caching functionality for MMTF
  Address jose comment on #558
  Also get short name when getting other protein aliases
  Fix bug with dihedral axis calculation #558
  Fix bug in superposeAndTransform method SuperPositions
  Remove tests that require String comparisons with floats
  ...
  • Loading branch information
andreasprlic committed Sep 21, 2016
2 parents 1937027 + 42724d1 commit c34385a
Show file tree
Hide file tree
Showing 196 changed files with 27,332 additions and 25,744 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -2,4 +2,5 @@ language: java
jdk:
- oraclejdk8
sudo: false

#after_success:
# - mvn clean cobertura:cobertura coveralls:report
2 changes: 1 addition & 1 deletion biojava-aa-prop/src/test/resources/log4j2.xml
Expand Up @@ -6,7 +6,7 @@
</Console>
</appenders>
<loggers>
<root level="info">
<root level="warn">
<appender-ref ref="Console"/>
</root>
</loggers>
Expand Down
5 changes: 0 additions & 5 deletions biojava-alignment/pom.xml
Expand Up @@ -73,10 +73,5 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.biojava</groupId>
<artifactId>biojava-phylo</artifactId>
<version>5.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Expand Up @@ -391,7 +391,7 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix pamMLdi
// Need to import PAM1 matrix to biojava TODO
//SubstitutionMatrix<AminoAcidCompound> PAM1 = SubstitutionMatrixHelper.getPAM250();

return null;
throw new IllegalStateException("PAM ML distance calculation not implemented!");
}

/**
Expand Down Expand Up @@ -447,18 +447,4 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix structu
return DM;
}

/**
* The joint sequence-structure distance (d<sub>SS</sub>) is a combination
* of the sequence-based and the structure-based distances.
*
* @param rmsdMat
* RMSD matrix for all structure pairs (symmetric matrix)
* @return DistanceMatrix
*/
public static <C extends Sequence<D>, D extends Compound> DistanceMatrix jointSeqStrucDistance(
double[][] rmsdMat) {
// TODO
return null;
}

}
Expand Up @@ -77,7 +77,7 @@ public void testComplex() throws Exception {

PairwiseSequenceAligner<DNASequence, NucleotideCompound> aligner = Alignments.getPairwiseAligner(a, b, Alignments.PairwiseSequenceAlignerType.GLOBAL, new SimpleGapPenalty(gop, gep), mx);
SequencePair<DNASequence, NucleotideCompound> pair = aligner.getPair();
System.out.println(pair); // prints the alignment above


int nMatches = "--CGTATATATCGCGCGCGCGATATATATATCT-TCTCTAAAAAAA".length() - 2 - 4;
double expectedScore = nMatches * match
Expand Down
2 changes: 1 addition & 1 deletion biojava-alignment/src/test/resources/log4j2.xml
Expand Up @@ -6,7 +6,7 @@
</Console>
</appenders>
<loggers>
<root level="info">
<root level="warn">
<appender-ref ref="Console"/>
</root>
</loggers>
Expand Down
Expand Up @@ -26,6 +26,7 @@
import org.biojava.nbio.core.sequence.Strand;
import org.biojava.nbio.core.sequence.features.FeatureInterface;
import org.biojava.nbio.core.sequence.features.Qualifier;
import org.biojava.nbio.core.sequence.location.template.AbstractLocation;
import org.biojava.nbio.core.sequence.location.template.Point;
import org.biojava.nbio.core.sequence.template.AbstractSequence;
import org.biojava.nbio.core.sequence.template.Compound;
Expand Down Expand Up @@ -186,7 +187,7 @@ private String _insdc_feature_location_string(FeatureInterface<AbstractSequence<
if(f.getLocations().getStrand() != Strand.NEGATIVE) {
StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter(sb,Locale.US);
formatter.format("Inconsistent strands: %r for parent, %r for child", feature.getLocations().getStrand(), f.getLocations().getStrand());
formatter.format("Inconsistent strands: %s for parent, %s for child", feature.getLocations().getStrand(), f.getLocations().getStrand());
String output = formatter.toString();
formatter.close();
throw new RuntimeException(output);
Expand Down Expand Up @@ -220,7 +221,7 @@ private String _insdc_feature_location_string(FeatureInterface<AbstractSequence<

private String _insdc_location_string_ignoring_strand_and_subfeatures(
//SequenceLocation<AbstractSequence<C>, C> sequenceLocation,
org.biojava.nbio.core.sequence.location.template.AbstractLocation sequenceLocation,
AbstractLocation sequenceLocation,
int record_length) {
/*
if location.ref:
Expand Down
Expand Up @@ -337,10 +337,21 @@ public ArrayList<AccessionID> getAccessions() throws XPathExpressionException {

/**
* Pull uniprot protein aliases associated with this sequence
* Provided for backwards compatibility now that we support both
* gene and protein aliases via separate methods.
* @return
* @throws XPathExpressionException
*/
public ArrayList<String> getAliases() throws XPathExpressionException {

return getProteinAliases();
}
/**
* Pull uniprot protein aliases associated with this sequence
* @return
* @throws XPathExpressionException
*/
public ArrayList<String> getProteinAliases() throws XPathExpressionException {
ArrayList<String> aliasList = new ArrayList<String>();
if (uniprotDoc == null) {
return aliasList;
Expand All @@ -353,6 +364,39 @@ public ArrayList<String> getAliases() throws XPathExpressionException {
Element fullNameElement = XMLHelper.selectSingleElement(element, "fullName");
aliasList.add(fullNameElement.getTextContent());
}
keyWordElementList = XMLHelper.selectElements(proteinElement, "recommendedName");
for (Element element : keyWordElementList) {
Element fullNameElement = XMLHelper.selectSingleElement(element, "fullName");
aliasList.add(fullNameElement.getTextContent());
Element shortNameElement = XMLHelper.selectSingleElement(element, "shortName");
if(null != shortNameElement) {
String shortName = shortNameElement.getTextContent();
if(null != shortName && !shortName.trim().isEmpty()) {
aliasList.add(shortName);
}
}
}

return aliasList;
}

/**
* Pull uniprot gene aliases associated with this sequence
* @return
* @throws XPathExpressionException
*/
public ArrayList<String> getGeneAliases() throws XPathExpressionException {
ArrayList<String> aliasList = new ArrayList<String>();
if (uniprotDoc == null) {
return aliasList;
}
Element uniprotElement = uniprotDoc.getDocumentElement();
Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry");
Element proteinElement = XMLHelper.selectSingleElement(entryElement, "gene");
ArrayList<Element> keyWordElementList = XMLHelper.selectElements(proteinElement, "name");
for (Element element : keyWordElementList) {
aliasList.add(element.getTextContent());
}

return aliasList;
}
Expand Down
Expand Up @@ -74,13 +74,13 @@ public void testProcess() throws Throwable {
= new GenbankProxySequenceReader<AminoAcidCompound>(System.getProperty("java.io.tmpdir"), "NP_000257", AminoAcidCompoundSet.getAminoAcidCompoundSet());
ProteinSequence proteinSequence = new ProteinSequence(genbankProteinReader);
genbankProteinReader.getHeaderParser().parseHeader(genbankProteinReader.getHeader(), proteinSequence);
logger.info("Sequence({},{}) = {}...", proteinSequence.getAccession(), proteinSequence.getLength(), proteinSequence.getSequenceAsString().substring(0, 10));
//logger.info("Sequence({},{}) = {}...", proteinSequence.getAccession(), proteinSequence.getLength(), proteinSequence.getSequenceAsString().substring(0, 10));

GenbankProxySequenceReader<NucleotideCompound> genbankDNAReader
= new GenbankProxySequenceReader<NucleotideCompound>(System.getProperty("java.io.tmpdir"), "NM_001126", DNACompoundSet.getDNACompoundSet());
DNASequence dnaSequence = new DNASequence(genbankDNAReader);
genbankDNAReader.getHeaderParser().parseHeader(genbankDNAReader.getHeader(), dnaSequence);
logger.info("Sequence({},{}) = {}...", dnaSequence.getAccession(), dnaSequence.getLength(), dnaSequence.getSequenceAsString().substring(0, 10));
//logger.info("Sequence({},{}) = {}...", dnaSequence.getAccession(), dnaSequence.getLength(), dnaSequence.getSequenceAsString().substring(0, 10));
/*
* Method 2: With the GenbankReaderHelper
*/
Expand All @@ -92,12 +92,12 @@ public void testProcess() throws Throwable {

LinkedHashMap<String, DNASequence> dnaSequences = GenbankReaderHelper.readGenbankDNASequence(dnaResource.getInputStream());
for (DNASequence sequence : dnaSequences.values()) {
logger.info("DNA Sequence: {}", sequence.getSequenceAsString());
logger.debug("DNA Sequence: {}", sequence.getSequenceAsString());
}

LinkedHashMap<String, ProteinSequence> protSequences = GenbankReaderHelper.readGenbankProteinSequence(protResource.getInputStream());
for (ProteinSequence sequence : protSequences.values()) {
logger.info("Protein Sequence: {}", sequence.getSequenceAsString());
logger.debug("Protein Sequence: {}", sequence.getSequenceAsString());
}
/*
* Method 3: With the GenbankReader Object
Expand All @@ -111,7 +111,7 @@ public void testProcess() throws Throwable {
);
dnaSequences = dnaReader.process();

logger.info("DNA Sequence: {}", dnaSequences);
logger.debug("DNA Sequence: {}", dnaSequences);


GenbankReader<ProteinSequence, AminoAcidCompound> protReader = new GenbankReader<ProteinSequence, AminoAcidCompound>(
Expand All @@ -121,7 +121,7 @@ public void testProcess() throws Throwable {
);
protSequences = protReader.process();

logger.info("Protein Sequence: {}", protSequences);
logger.debug("Protein Sequence: {}", protSequences);

}

Expand Down
Expand Up @@ -128,7 +128,7 @@ public void CDStest() throws Exception {


Assert.assertTrue(proteinSequences.size() == 1);
logger.info("protein sequences: {}", proteinSequences);
logger.debug("protein sequences: {}", proteinSequences);

ProteinSequence protein = new ArrayList<ProteinSequence>(proteinSequences.values()).get(0);

Expand Down
27 changes: 9 additions & 18 deletions biojava-core/src/test/resources/log4j2.xml
@@ -1,22 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<configuration status="WARN">
<appenders>
<Console name="Console" target="SYSTEM_ERR">
<PatternLayout pattern="%d{HH:mm:ss} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<!--
<Logger name="org.biojava.nbio.core.sequence.loader.GenbankProxySequenceReader" level="debug">
<AppenderRef ref="Console"/>
</Logger>
-->
<!--
<Logger name="org.biojava.nbio.core.sequence.location.InsdcParserTest" level="debug" />
-->

<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
</appenders>
<loggers>
<root level="warn">
<appender-ref ref="Console"/>
</root>
</loggers>
</configuration>
Expand Up @@ -286,34 +286,41 @@ public Location union( Location other )
}

/**
* Return the intersection, or null if no overlap.
*
* @param other The location to intersect.
* @return The maximal location that is contained by both. Returns null if no overlap!
* @throws IllegalArgumentException Locations are on opposite strands.
*/
public Location intersection( Location other )
{
if( isSameStrand( other ) )
{
int start= ( mStart > other.mStart)? mStart: other.mStart; //pick larger
int end= ( mEnd < other.mEnd)? mEnd: other.mEnd; //pick smaller

if( start <= end )
{
return new Location( start, end );
}
else
{
return null;
}
}
else
{
throw new IllegalArgumentException( "Locations are on opposite strands." );
}
* Return the intersection, or null if no overlap.
*
* @param other
* The location to intersect.
* @return The maximal location that is contained by both. Returns null if
* no overlap!
* @throws IllegalArgumentException
* Locations are on opposite strands.
*/
public Location intersection(Location other) {
if (isSameStrand(other)) {
return intersect(mStart, mEnd, other.mStart, other.mEnd);
} else {
throw new IllegalArgumentException("Locations are on opposite strands.");
}
}

private Location intersect(int a1, int a2, int b1, int b2) {
if (a1 > b1) {
return intersect(b1, b2, a1, a2);
}
// Safe to assume a1 <= b1
if (b1 >= a2) {
// b starts after a ends
return null;
} else if (b1 < a2 && b2 <= a2) {
// b starts after a starts and ends before or at where a ends
return new Location(b1, b2);
} else if (b1 >= a1 && a2 <= b2) {
// b starts after a but extends after the end of a
return new Location(b1, a2);
}
return null;
}

}

/**
* Get starting index (origin 0).
Expand Down

0 comments on commit c34385a

Please sign in to comment.