Skip to content

Commit 11b3f23

Browse files
committed
Merge branch 'master' into quatalign
2 parents 8946b08 + 3c3e018 commit 11b3f23

File tree

71 files changed

+1230
-576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1230
-576
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ language: java
22
jdk:
33
- oraclejdk8
44
sudo: false
5-
5+
#after_success:
6+
# - mvn clean cobertura:cobertura coveralls:report

biojava-aa-prop/src/test/resources/log4j2.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</Console>
77
</appenders>
88
<loggers>
9-
<root level="info">
9+
<root level="warn">
1010
<appender-ref ref="Console"/>
1111
</root>
1212
</loggers>

biojava-alignment/src/test/java/org/biojava/nbio/alignment/NeedlemanWunschTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void testComplex() throws Exception {
7777

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

8282
int nMatches = "--CGTATATATCGCGCGCGCGATATATATATCT-TCTCTAAAAAAA".length() - 2 - 4;
8383
double expectedScore = nMatches * match

biojava-alignment/src/test/resources/log4j2.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</Console>
77
</appenders>
88
<loggers>
9-
<root level="info">
9+
<root level="warn">
1010
<appender-ref ref="Console"/>
1111
</root>
1212
</loggers>

biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericInsdcHeaderFormat.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.biojava.nbio.core.sequence.Strand;
2727
import org.biojava.nbio.core.sequence.features.FeatureInterface;
2828
import org.biojava.nbio.core.sequence.features.Qualifier;
29+
import org.biojava.nbio.core.sequence.location.template.AbstractLocation;
2930
import org.biojava.nbio.core.sequence.location.template.Point;
3031
import org.biojava.nbio.core.sequence.template.AbstractSequence;
3132
import org.biojava.nbio.core.sequence.template.Compound;
@@ -186,7 +187,7 @@ private String _insdc_feature_location_string(FeatureInterface<AbstractSequence<
186187
if(f.getLocations().getStrand() != Strand.NEGATIVE) {
187188
StringBuilder sb = new StringBuilder();
188189
Formatter formatter = new Formatter(sb,Locale.US);
189-
formatter.format("Inconsistent strands: %r for parent, %r for child", feature.getLocations().getStrand(), f.getLocations().getStrand());
190+
formatter.format("Inconsistent strands: %s for parent, %s for child", feature.getLocations().getStrand(), f.getLocations().getStrand());
190191
String output = formatter.toString();
191192
formatter.close();
192193
throw new RuntimeException(output);
@@ -220,7 +221,7 @@ private String _insdc_feature_location_string(FeatureInterface<AbstractSequence<
220221

221222
private String _insdc_location_string_ignoring_strand_and_subfeatures(
222223
//SequenceLocation<AbstractSequence<C>, C> sequenceLocation,
223-
org.biojava.nbio.core.sequence.location.template.AbstractLocation sequenceLocation,
224+
AbstractLocation sequenceLocation,
224225
int record_length) {
225226
/*
226227
if location.ref:

biojava-core/src/main/java/org/biojava/nbio/core/sequence/loader/UniprotProxySequenceReader.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,21 @@ public ArrayList<AccessionID> getAccessions() throws XPathExpressionException {
337337

338338
/**
339339
* Pull uniprot protein aliases associated with this sequence
340+
* Provided for backwards compatibility now that we support both
341+
* gene and protein aliases via separate methods.
340342
* @return
341343
* @throws XPathExpressionException
342344
*/
343345
public ArrayList<String> getAliases() throws XPathExpressionException {
346+
347+
return getProteinAliases();
348+
}
349+
/**
350+
* Pull uniprot protein aliases associated with this sequence
351+
* @return
352+
* @throws XPathExpressionException
353+
*/
354+
public ArrayList<String> getProteinAliases() throws XPathExpressionException {
344355
ArrayList<String> aliasList = new ArrayList<String>();
345356
if (uniprotDoc == null) {
346357
return aliasList;
@@ -353,6 +364,32 @@ public ArrayList<String> getAliases() throws XPathExpressionException {
353364
Element fullNameElement = XMLHelper.selectSingleElement(element, "fullName");
354365
aliasList.add(fullNameElement.getTextContent());
355366
}
367+
keyWordElementList = XMLHelper.selectElements(proteinElement, "recommendedName");
368+
for (Element element : keyWordElementList) {
369+
Element fullNameElement = XMLHelper.selectSingleElement(element, "fullName");
370+
aliasList.add(fullNameElement.getTextContent());
371+
}
372+
373+
return aliasList;
374+
}
375+
376+
/**
377+
* Pull uniprot gene aliases associated with this sequence
378+
* @return
379+
* @throws XPathExpressionException
380+
*/
381+
public ArrayList<String> getGeneAliases() throws XPathExpressionException {
382+
ArrayList<String> aliasList = new ArrayList<String>();
383+
if (uniprotDoc == null) {
384+
return aliasList;
385+
}
386+
Element uniprotElement = uniprotDoc.getDocumentElement();
387+
Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry");
388+
Element proteinElement = XMLHelper.selectSingleElement(entryElement, "gene");
389+
ArrayList<Element> keyWordElementList = XMLHelper.selectElements(proteinElement, "name");
390+
for (Element element : keyWordElementList) {
391+
aliasList.add(element.getTextContent());
392+
}
356393

357394
return aliasList;
358395
}

biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankCookbookTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ public void testProcess() throws Throwable {
7474
= new GenbankProxySequenceReader<AminoAcidCompound>(System.getProperty("java.io.tmpdir"), "NP_000257", AminoAcidCompoundSet.getAminoAcidCompoundSet());
7575
ProteinSequence proteinSequence = new ProteinSequence(genbankProteinReader);
7676
genbankProteinReader.getHeaderParser().parseHeader(genbankProteinReader.getHeader(), proteinSequence);
77-
logger.info("Sequence({},{}) = {}...", proteinSequence.getAccession(), proteinSequence.getLength(), proteinSequence.getSequenceAsString().substring(0, 10));
77+
//logger.info("Sequence({},{}) = {}...", proteinSequence.getAccession(), proteinSequence.getLength(), proteinSequence.getSequenceAsString().substring(0, 10));
7878

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

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

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

114-
logger.info("DNA Sequence: {}", dnaSequences);
114+
logger.debug("DNA Sequence: {}", dnaSequences);
115115

116116

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

124-
logger.info("Protein Sequence: {}", protSequences);
124+
logger.debug("Protein Sequence: {}", protSequences);
125125

126126
}
127127

biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankReaderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void CDStest() throws Exception {
128128

129129

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

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

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<Configuration status="WARN">
3-
<Appenders>
2+
<configuration status="WARN">
3+
<appenders>
44
<Console name="Console" target="SYSTEM_ERR">
55
<PatternLayout pattern="%d{HH:mm:ss} [%t] %-5level %logger{36} - %msg%n"/>
66
</Console>
7-
</Appenders>
8-
<Loggers>
9-
<!--
10-
<Logger name="org.biojava.nbio.core.sequence.loader.GenbankProxySequenceReader" level="debug">
11-
<AppenderRef ref="Console"/>
12-
</Logger>
13-
-->
14-
<!--
15-
<Logger name="org.biojava.nbio.core.sequence.location.InsdcParserTest" level="debug" />
16-
-->
17-
18-
<Root level="info">
19-
<AppenderRef ref="Console"/>
20-
</Root>
21-
</Loggers>
22-
</Configuration>
7+
</appenders>
8+
<loggers>
9+
<root level="warn">
10+
<appender-ref ref="Console"/>
11+
</root>
12+
</loggers>
13+
</configuration>

biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/Location.java

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -286,34 +286,41 @@ public Location union( Location other )
286286
}
287287

288288
/**
289-
* Return the intersection, or null if no overlap.
290-
*
291-
* @param other The location to intersect.
292-
* @return The maximal location that is contained by both. Returns null if no overlap!
293-
* @throws IllegalArgumentException Locations are on opposite strands.
294-
*/
295-
public Location intersection( Location other )
296-
{
297-
if( isSameStrand( other ) )
298-
{
299-
int start= ( mStart > other.mStart)? mStart: other.mStart; //pick larger
300-
int end= ( mEnd < other.mEnd)? mEnd: other.mEnd; //pick smaller
301-
302-
if( start <= end )
303-
{
304-
return new Location( start, end );
305-
}
306-
else
307-
{
308-
return null;
309-
}
310-
}
311-
else
312-
{
313-
throw new IllegalArgumentException( "Locations are on opposite strands." );
314-
}
289+
* Return the intersection, or null if no overlap.
290+
*
291+
* @param other
292+
* The location to intersect.
293+
* @return The maximal location that is contained by both. Returns null if
294+
* no overlap!
295+
* @throws IllegalArgumentException
296+
* Locations are on opposite strands.
297+
*/
298+
public Location intersection(Location other) {
299+
if (isSameStrand(other)) {
300+
return intersect(mStart, mEnd, other.mStart, other.mEnd);
301+
} else {
302+
throw new IllegalArgumentException("Locations are on opposite strands.");
303+
}
304+
}
305+
306+
private Location intersect(int a1, int a2, int b1, int b2) {
307+
if (a1 > b1) {
308+
return intersect(b1, b2, a1, a2);
309+
}
310+
// Safe to assume a1 <= b1
311+
if (b1 >= a2) {
312+
// b starts after a ends
313+
return null;
314+
} else if (b1 < a2 && b2 <= a2) {
315+
// b starts after a starts and ends before or at where a ends
316+
return new Location(b1, b2);
317+
} else if (b1 >= a1 && a2 <= b2) {
318+
// b starts after a but extends after the end of a
319+
return new Location(b1, a2);
320+
}
321+
return null;
322+
}
315323

316-
}
317324

318325
/**
319326
* Get starting index (origin 0).

0 commit comments

Comments
 (0)