import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
/**
* Base class for Ensembl sequence fetchers
// danger: accession separator used as a regex here, a string elsewhere
// in this case it is ok (it is just a space), but (e.g.) '\' would not be
- List<String> allIds = Arrays.asList(query
- .split(getAccessionSeparator()));
+ List<String> allIds = Arrays
+ .asList(query.split(getAccessionSeparator()));
AlignmentI alignment = null;
inProgress = true;
}
} catch (IOException e)
{
- System.err.println("Error transferring Ensembl features: "
- + e.getMessage());
+ System.err.println(
+ "Error transferring Ensembl features: " + e.getMessage());
}
}
proteinSeq.createDatasetSequence();
querySeq.createDatasetSequence();
- MapList mapList = AlignmentUtils
- .mapCdsToProtein(querySeq, proteinSeq);
+ MapList mapList = AlignmentUtils.mapCdsToProtein(querySeq,
+ proteinSeq);
if (mapList != null)
{
// clunky: ensure Uniprot xref if we have one is on mapped sequence
getEnsemblDataVersion(), proteinSeq.getName(), map);
querySeq.getDatasetSequence().addDBRef(dbr);
DBRefEntry[] uprots = DBRefUtils.selectRefs(ds.getDBRefs(),
- new String[] { DBRefSource.UNIPROT });
+ new String[]
+ { DBRefSource.UNIPROT });
DBRefEntry[] upxrefs = DBRefUtils.selectRefs(querySeq.getDBRefs(),
- new String[] { DBRefSource.UNIPROT });
+ new String[]
+ { DBRefSource.UNIPROT });
if (uprots != null)
{
for (DBRefEntry up : uprots)
if (upx.size() > 1)
{
- Cache.log
- .warn("Implementation issue - multiple uniprot acc on product sequence.");
+ Cache.log.warn(
+ "Implementation issue - multiple uniprot acc on product sequence.");
}
}
else
* copy exon features to protein, compute peptide variants from dna
* variants and add as features on the protein sequence ta-da
*/
- AlignmentUtils
- .computeProteinFeatures(querySeq, proteinSeq, mapList);
+ AlignmentUtils.computeProteinFeatures(querySeq, proteinSeq,
+ mapList);
}
} catch (Exception e)
{
/*
* and add a reference to itself
*/
- DBRefEntry self = new DBRefEntry(getDbSource(),
- getEnsemblDataVersion(), seq.getName());
+ DBRefEntry self = new DBRefEntry(getDbSource(), getEnsemblDataVersion(),
+ seq.getName());
seq.addDBRef(self);
}
* @throws JalviewException
* @throws IOException
*/
- protected AlignmentI fetchSequences(List<String> ids, AlignmentI alignment)
- throws JalviewException, IOException
+ protected AlignmentI fetchSequences(List<String> ids,
+ AlignmentI alignment) throws JalviewException, IOException
{
if (!isEnsemblAvailable())
{
FastaFile fr = new FastaFile(fp);
if (fr.hasWarningMessage())
{
- System.out.println(String.format(
- "Warning when retrieving %d ids %s\n%s", ids.size(),
- ids.toString(), fr.getWarningMessage()));
+ System.out.println(
+ String.format("Warning when retrieving %d ids %s\n%s",
+ ids.size(), ids.toString(), fr.getWarningMessage()));
}
else if (fr.getSeqs().size() != ids.size())
{
System.out.println(String.format(
- "Only retrieved %d sequences for %d query strings", fr
- .getSeqs().size(), ids.size()));
+ "Only retrieved %d sequences for %d query strings",
+ fr.getSeqs().size(), ids.size()));
}
if (fr.getSeqs().size() == 1 && fr.getSeqs().get(0).getLength() == 0)
urlstring.append("?type=").append(getSourceEnsemblType().getType());
urlstring.append(("&Accept=text/x-fasta"));
+ Map<String, String> params = getAdditionalParameters();
+ if (params != null)
+ {
+ for (Entry<String, String> entry : params.entrySet())
+ {
+ urlstring.append("&").append(entry.getKey()).append("=")
+ .append(entry.getValue());
+ }
+ }
+
URL url = new URL(urlstring.toString());
return url;
}
/**
+ * Override this method to add any additional x=y URL parameters needed
+ *
+ * @return
+ */
+ protected Map<String, String> getAdditionalParameters()
+ {
+ return null;
+ }
+
+ /**
* A sequence/id POST request currently allows up to 50 queries
*
* @see http://rest.ensembl.org/documentation/info/sequence_id_post
if (directionSet && strand != direction)
{
// abort - mix of forward and backward
- System.err.println("Error: forward and backward strand for "
- + accId);
+ System.err.println(
+ "Error: forward and backward strand for " + accId);
return null;
}
direction = strand;
Collections.sort(regions, direction == 1 ? IntRangeComparator.ASCENDING
: IntRangeComparator.DESCENDING);
- List<int[]> to = Arrays.asList(new int[] { start,
- start + mappedLength - 1 });
+ List<int[]> to = Arrays
+ .asList(new int[]
+ { start, start + mappedLength - 1 });
return new MapList(regions, to, 1, 1);
}
int newBegin = Math.min(mappedRange[0], mappedRange[1]);
int newEnd = Math.max(mappedRange[0], mappedRange[1]);
SequenceFeature copy = new SequenceFeature(sf, newBegin, newEnd,
- group);
+ group, sf.getScore());
targetSequence.addSequenceFeature(copy);
/*
* for sequence_variant on reverse strand, have to convert the allele
* values to their complements
*/
- if (!forwardStrand
- && SequenceOntologyFactory.getInstance().isA(sf.getType(),
- SequenceOntologyI.SEQUENCE_VARIANT))
+ if (!forwardStrand && SequenceOntologyFactory.getInstance()
+ .isA(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT))
{
reverseComplementAlleles(copy);
}