Class AbstractCsvStreamSource<T extends InteractionEvidence>
- java.lang.Object
-
- psidev.psi.mi.jami.crosslink.extension.datasource.AbstractCsvStreamSource<T>
-
- All Implemented Interfaces:
CsvStreamSource<T>,CsvParserListener,InteractionEvidenceStream<T>,InteractionStream<T>,MIDataSource,MIFileDataSource,MIFileParserListener
- Direct Known Subclasses:
CsvBinaryEvidenceStreamSource,CsvEvidenceStreamSource
public abstract class AbstractCsvStreamSource<T extends InteractionEvidence> extends Object implements CsvStreamSource<T>
abstract class for Crosslink Csv datasource. This datasource loads all the interactions from a Crosslink CSV file- Since:
21/06/13
- Version:
- $Id$
- Author:
- Marine Dumousseau (marine@ebi.ac.uk)
-
-
Field Summary
-
Fields inherited from interface psidev.psi.mi.jami.datasource.MIFileDataSource
FILE_URI_PREFIX, URL_PREFIX_REGEXP
-
-
Constructor Summary
Constructors Constructor Description AbstractCsvStreamSource()Empty constructor for the factoryAbstractCsvStreamSource(File file)Constructor for AbstractCsvStreamSource.AbstractCsvStreamSource(InputStream input)Constructor for AbstractCsvStreamSource.AbstractCsvStreamSource(Reader reader)Constructor for AbstractCsvStreamSource.AbstractCsvStreamSource(URL url)Constructor for AbstractCsvStreamSource.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()close.protected Iterator<T>createCsvIterator()createCsvIterator.MIFileParserListenergetFileParserListener()getFileParserListener.Iterator<T>getInteractionsIterator()getInteractionsIterator.protected AbstractCsvInteractionEvidenceParser<T>getLineParser()Getter for the fieldlineParser.voidinitialiseContext(Map<String,Object> options)Initialise the context of the MIDataSource given a map of optionsprotected abstract AbstractCsvInteractionEvidenceParser<T>instantiateLineParser()instantiateLineParser.voidonAliasWithoutName(FileSourceContext context)Listen to an event fired when an alias does not have a namevoidonAnnotationWithoutTopic(FileSourceContext context)Listen to an event fired when an annotation does not have a topicvoidonInteractionWithoutParticipants(Interaction interaction, FileSourceContext context)Listen to an event fired when an interaction is read and does not have any participants.voidonInvalidOrganismTaxid(String taxid, FileSourceContext context)Listen to an event fired when an organism does not have a valid taxid (positive integer or -1, -2, -3, -4, -5)voidonInvalidPosition(String message, FileSourceContext context)Listen to an event fired when a position is not validvoidonInvalidProteinIdentifierSyntax(String[] identifiers, int lineNumber, int columnNumber)Event fired when we don't find protein xrefs with db|uniprotId|namevoidonInvalidRange(String message, FileSourceContext context)Listen to an event fired when a range is not validvoidonInvalidStoichiometry(String message, FileSourceContext context)Listen to an event fired when a stoichiometry is not validvoidonInvalidSyntax(FileSourceContext context, Exception e)Listen to an invalid syntax causing an ExceptionvoidonMismatchBetweenPeptideAndLinkedPositions(List<CsvRange> peptidePositions, List<CsvRange> linkedPositions)Event fired when the number of peptide positions is greater than one and is not the same as the number of linked positionsvoidonMismatchBetweenRangePositionsAndProteins(List<CsvRange> rangePositions, List<CsvProtein> proteins)Event fired when the number of range positions is superior to 1 and the number of proteins is also superior to 1 but does not match the number of rangesvoidonMissingChecksumMethod(FileSourceContext context)Listen to an event fired when a checksum does not have a methodvoidonMissingChecksumValue(FileSourceContext context)Listen to an event fired when a checksum does not have a valuevoidonMissingConfidenceType(FileSourceContext context)Listen to an event fired when a confidence does not have a confidence typevoidonMissingConfidenceValue(FileSourceContext context)Listen to an event fired when a confidence does not have a valuevoidonMissingCvTermName(CvTerm term, FileSourceContext context, String message)Listen to an event fired when a CvTerm is read and does not have any names.voidonMissingInteractorName(Interactor interactor, FileSourceContext context)Listen to an event fired when an interactor is read and does not have any names.voidonMissingParameterType(FileSourceContext context)Listen to an event fired when a parameter does not have a typevoidonMissingParameterValue(FileSourceContext context)Listen to an event fired when a parameter does not have a valuevoidonMissingProtein1Column(int lineNumber)Event fired when the column Protein1 is missing or emptyvoidonParticipantWithoutInteractor(Participant participant, FileSourceContext context)Listen to en event fired when a Participant is read and no interactor details has been provided.voidonSyntaxWarning(FileSourceContext context, String message)Listen to an event fired when the syntax of the file is valid but the content is not expected or some information may be lost.voidonXrefWithoutDatabase(FileSourceContext context)Listen to an event fired when a xref does not have a databasevoidonXrefWithoutId(FileSourceContext context)Listen to an event fired when a xref does not have an idprotected voidreInit()reInit.voidreset()reset.protected voidsetCsvFileParserListener(CsvParserListener listener)setCsvFileParserListener.voidsetFileParserListener(MIFileParserListener listener)setFileParserListenerprotected voidsetLineParser(AbstractCsvInteractionEvidenceParser<T> lineParser)Setter for the fieldlineParser.protected voidsetMIFileParserListener(MIFileParserListener listener)setMIFileParserListener.protected voidsetOriginalFile(File originalFile)Setter for the fieldoriginalFile.protected voidsetOriginalReader(Reader originalReader)Setter for the fieldoriginalReader.protected voidsetOriginalStream(InputStream originalStream)Setter for the fieldoriginalStream.protected voidsetOriginalURL(URL originalURL)Setter for the fieldoriginalURL.booleanvalidateSyntax()validateSyntax.booleanvalidateSyntax(MIFileParserListener listener)Validate the syntax of this MIFileDataSource and uses the provided MIFileParserListener to listen to the events.
-
-
-
Constructor Detail
-
AbstractCsvStreamSource
public AbstractCsvStreamSource()
Empty constructor for the factory
-
AbstractCsvStreamSource
public AbstractCsvStreamSource(File file) throws IOException
Constructor for AbstractCsvStreamSource.
- Parameters:
file- aFileobject.- Throws:
IOException- if any.
-
AbstractCsvStreamSource
public AbstractCsvStreamSource(InputStream input)
Constructor for AbstractCsvStreamSource.
- Parameters:
input- aInputStreamobject.
-
AbstractCsvStreamSource
public AbstractCsvStreamSource(Reader reader)
Constructor for AbstractCsvStreamSource.
- Parameters:
reader- aReaderobject.
-
-
Method Detail
-
getFileParserListener
public MIFileParserListener getFileParserListener()
getFileParserListener.
- Specified by:
getFileParserListenerin interfaceMIFileDataSource- Returns:
- a
MIFileParserListenerobject.
-
setFileParserListener
public void setFileParserListener(MIFileParserListener listener)
setFileParserListener
- Specified by:
setFileParserListenerin interfaceMIFileDataSource- Parameters:
listener- aMIFileParserListenerobject.
-
initialiseContext
public void initialiseContext(Map<String,Object> options)
Initialise the context of the MIDataSource given a map of options- Specified by:
initialiseContextin interfaceMIDataSource- Parameters:
options- : the options provided by the user
-
close
public void close() throws MIIOExceptionclose.
- Specified by:
closein interfaceMIDataSource- Throws:
MIIOException- if any.
-
reset
public void reset() throws MIIOExceptionreset.
- Specified by:
resetin interfaceMIDataSource- Throws:
MIIOException- if any.
-
validateSyntax
public boolean validateSyntax(MIFileParserListener listener)
Validate the syntax of this MIFileDataSource and uses the provided MIFileParserListener to listen to the events. The provided listener will be set as the MIFileParserListener of this datasource- Specified by:
validateSyntaxin interfaceMIFileDataSource- Parameters:
listener- : the listener for parsing events- Returns:
- true if the file syntax is valid
-
validateSyntax
public boolean validateSyntax()
validateSyntax.
- Specified by:
validateSyntaxin interfaceMIFileDataSource- Returns:
- a boolean.
-
onInvalidSyntax
public void onInvalidSyntax(FileSourceContext context, Exception e)
Listen to an invalid syntax causing an Exception- Specified by:
onInvalidSyntaxin interfaceMIFileParserListener- Parameters:
context- : file contexte- aExceptionobject.
-
onSyntaxWarning
public void onSyntaxWarning(FileSourceContext context, String message)
Listen to an event fired when the syntax of the file is valid but the content is not expected or some information may be lost.- Specified by:
onSyntaxWarningin interfaceMIFileParserListener- Parameters:
context- : file contextmessage- : warning message
-
onMissingCvTermName
public void onMissingCvTermName(CvTerm term, FileSourceContext context, String message)
Listen to an event fired when a CvTerm is read and does not have any names. At least a shortname is expected for each CvTerm so such a term may be loaded with an automatically generated shortname.- Specified by:
onMissingCvTermNamein interfaceMIFileParserListener- Parameters:
term- : cv without namecontext- : file contextmessage- : error message
-
onMissingInteractorName
public void onMissingInteractorName(Interactor interactor, FileSourceContext context)
Listen to an event fired when an interactor is read and does not have any names. At least a shortname is expected for each interactor so such an interactor may be loaded with an automatically generated shortname.- Specified by:
onMissingInteractorNamein interfaceMIFileParserListener- Parameters:
interactor- : interactor without namecontext- : file context
-
onMismatchBetweenPeptideAndLinkedPositions
public void onMismatchBetweenPeptideAndLinkedPositions(List<CsvRange> peptidePositions, List<CsvRange> linkedPositions)
Event fired when the number of peptide positions is greater than one and is not the same as the number of linked positions- Specified by:
onMismatchBetweenPeptideAndLinkedPositionsin interfaceCsvParserListener- Parameters:
peptidePositions- : peptide positions in protein sequencelinkedPositions- : linked feature positions relative to peptide positions
-
onMismatchBetweenRangePositionsAndProteins
public void onMismatchBetweenRangePositionsAndProteins(List<CsvRange> rangePositions, List<CsvProtein> proteins)
Event fired when the number of range positions is superior to 1 and the number of proteins is also superior to 1 but does not match the number of ranges- Specified by:
onMismatchBetweenRangePositionsAndProteinsin interfaceCsvParserListener- Parameters:
rangePositions- : feature rangesproteins- : proteins
-
onInvalidProteinIdentifierSyntax
public void onInvalidProteinIdentifierSyntax(String[] identifiers, int lineNumber, int columnNumber)
Event fired when we don't find protein xrefs with db|uniprotId|name- Specified by:
onInvalidProteinIdentifierSyntaxin interfaceCsvParserListener- Parameters:
identifiers- : the identifierslineNumber- a int.columnNumber- a int.
-
onMissingProtein1Column
public void onMissingProtein1Column(int lineNumber)
Event fired when the column Protein1 is missing or empty- Specified by:
onMissingProtein1Columnin interfaceCsvParserListener- Parameters:
lineNumber- : line number
-
onParticipantWithoutInteractor
public void onParticipantWithoutInteractor(Participant participant, FileSourceContext context)
Listen to en event fired when a Participant is read and no interactor details has been provided. In such a case, the interactor can be automatically generated as an unknown interactor- Specified by:
onParticipantWithoutInteractorin interfaceMIFileParserListener- Parameters:
participant- : participant without interactorcontext- : file context
-
onInteractionWithoutParticipants
public void onInteractionWithoutParticipants(Interaction interaction, FileSourceContext context)
Listen to an event fired when an interaction is read and does not have any participants. The interaction may be loaded as an empty interaction.- Specified by:
onInteractionWithoutParticipantsin interfaceMIFileParserListener- Parameters:
interaction- : interaction without participantscontext- : file context
-
onInvalidOrganismTaxid
public void onInvalidOrganismTaxid(String taxid, FileSourceContext context)
Listen to an event fired when an organism does not have a valid taxid (positive integer or -1, -2, -3, -4, -5)- Specified by:
onInvalidOrganismTaxidin interfaceMIFileParserListener- Parameters:
taxid- : invalid taxidcontext- : file context
-
onMissingParameterValue
public void onMissingParameterValue(FileSourceContext context)
Listen to an event fired when a parameter does not have a value- Specified by:
onMissingParameterValuein interfaceMIFileParserListener- Parameters:
context- : file context
-
onMissingParameterType
public void onMissingParameterType(FileSourceContext context)
Listen to an event fired when a parameter does not have a type- Specified by:
onMissingParameterTypein interfaceMIFileParserListener- Parameters:
context- : file context
-
onMissingConfidenceValue
public void onMissingConfidenceValue(FileSourceContext context)
Listen to an event fired when a confidence does not have a value- Specified by:
onMissingConfidenceValuein interfaceMIFileParserListener- Parameters:
context- : file context
-
onMissingConfidenceType
public void onMissingConfidenceType(FileSourceContext context)
Listen to an event fired when a confidence does not have a confidence type- Specified by:
onMissingConfidenceTypein interfaceMIFileParserListener- Parameters:
context- : file context
-
onMissingChecksumValue
public void onMissingChecksumValue(FileSourceContext context)
Listen to an event fired when a checksum does not have a value- Specified by:
onMissingChecksumValuein interfaceMIFileParserListener- Parameters:
context- : file context
-
onMissingChecksumMethod
public void onMissingChecksumMethod(FileSourceContext context)
Listen to an event fired when a checksum does not have a method- Specified by:
onMissingChecksumMethodin interfaceMIFileParserListener- Parameters:
context- : file context
-
onInvalidPosition
public void onInvalidPosition(String message, FileSourceContext context)
Listen to an event fired when a position is not valid- Specified by:
onInvalidPositionin interfaceMIFileParserListener- Parameters:
message- : error messagecontext- : file context
-
onInvalidRange
public void onInvalidRange(String message, FileSourceContext context)
Listen to an event fired when a range is not valid- Specified by:
onInvalidRangein interfaceMIFileParserListener- Parameters:
message- : error messagecontext- : file context
-
onInvalidStoichiometry
public void onInvalidStoichiometry(String message, FileSourceContext context)
Listen to an event fired when a stoichiometry is not valid- Specified by:
onInvalidStoichiometryin interfaceMIFileParserListener- Parameters:
message- : : error messagecontext- : file context
-
onXrefWithoutDatabase
public void onXrefWithoutDatabase(FileSourceContext context)
Listen to an event fired when a xref does not have a database- Specified by:
onXrefWithoutDatabasein interfaceMIFileParserListener- Parameters:
context- : file context
-
onXrefWithoutId
public void onXrefWithoutId(FileSourceContext context)
Listen to an event fired when a xref does not have an id- Specified by:
onXrefWithoutIdin interfaceMIFileParserListener- Parameters:
context- : file context
-
onAnnotationWithoutTopic
public void onAnnotationWithoutTopic(FileSourceContext context)
Listen to an event fired when an annotation does not have a topic- Specified by:
onAnnotationWithoutTopicin interfaceMIFileParserListener- Parameters:
context- : file context
-
onAliasWithoutName
public void onAliasWithoutName(FileSourceContext context)
Listen to an event fired when an alias does not have a name- Specified by:
onAliasWithoutNamein interfaceMIFileParserListener- Parameters:
context- : file context
-
getInteractionsIterator
public Iterator<T> getInteractionsIterator()
getInteractionsIterator.
- Specified by:
getInteractionsIteratorin interfaceInteractionStream<T extends InteractionEvidence>- Returns:
- a
Iteratorobject.
-
getLineParser
protected AbstractCsvInteractionEvidenceParser<T> getLineParser()
Getter for the field
lineParser.- Returns:
- a
AbstractCsvInteractionEvidenceParserobject.
-
setLineParser
protected void setLineParser(AbstractCsvInteractionEvidenceParser<T> lineParser)
Setter for the field
lineParser.- Parameters:
lineParser- aAbstractCsvInteractionEvidenceParserobject.
-
createCsvIterator
protected Iterator<T> createCsvIterator()
createCsvIterator.
- Returns:
- a
Iteratorobject.
-
reInit
protected void reInit() throws MIIOExceptionreInit.
- Throws:
MIIOException- if any.
-
instantiateLineParser
protected abstract AbstractCsvInteractionEvidenceParser<T> instantiateLineParser()
instantiateLineParser.
- Returns:
- a
AbstractCsvInteractionEvidenceParserobject.
-
setOriginalFile
protected void setOriginalFile(File originalFile)
Setter for the field
originalFile.- Parameters:
originalFile- aFileobject.
-
setOriginalStream
protected void setOriginalStream(InputStream originalStream)
Setter for the field
originalStream.- Parameters:
originalStream- aInputStreamobject.
-
setOriginalReader
protected void setOriginalReader(Reader originalReader)
Setter for the field
originalReader.- Parameters:
originalReader- aReaderobject.
-
setOriginalURL
protected void setOriginalURL(URL originalURL)
Setter for the field
originalURL.- Parameters:
originalURL- aURLobject.
-
setCsvFileParserListener
protected void setCsvFileParserListener(CsvParserListener listener)
setCsvFileParserListener.
- Parameters:
listener- aCsvParserListenerobject.
-
setMIFileParserListener
protected void setMIFileParserListener(MIFileParserListener listener)
setMIFileParserListener.
- Parameters:
listener- aMIFileParserListenerobject.
-
-