Class AbstractMitabStreamSource<T extends Interaction,P extends Participant,F extends Feature>
- java.lang.Object
-
- psidev.psi.mi.jami.tab.extension.datasource.AbstractMitabStreamSource<T,P,F>
-
- All Implemented Interfaces:
InteractionStream<T>
,MIDataSource
,MIFileDataSource
,MIFileParserListener
,MitabStreamSource<T>
,MitabParserListener
- Direct Known Subclasses:
LightMitabBinaryStreamSource
,LightMitabStreamSource
,MitabBinaryEvidenceStreamSource
,MitabEvidenceStreamSource
,MitabModelledBinaryStreamSource
,MitabModelledStreamSource
public abstract class AbstractMitabStreamSource<T extends Interaction,P extends Participant,F extends Feature> extends Object implements MitabStreamSource<T>
abstract class for Mitab datasource. This datasource loads all the interactions from a MITAB 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 AbstractMitabStreamSource()
Empty constructor for the factoryAbstractMitabStreamSource(File file)
Constructor for AbstractMitabStreamSource.AbstractMitabStreamSource(InputStream input)
Constructor for AbstractMitabStreamSource.AbstractMitabStreamSource(Reader reader)
Constructor for AbstractMitabStreamSource.AbstractMitabStreamSource(URL url)
Constructor for AbstractMitabStreamSource.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
close.protected abstract Iterator<T>
createMitabIterator()
createMitabIterator.MIFileParserListener
getFileParserListener()
getFileParserListener.Iterator<T>
getInteractionsIterator()
getInteractionsIterator.InteractorFactory
getInteractorFactory()
Getter for the fieldinteractorFactory
.protected MitabLineParser<T,P,F>
getLineParser()
Getter for the fieldlineParser
.void
initialiseContext(Map<String,Object> options)
Initialise the context of the MIDataSource given a map of optionsprotected abstract void
initialiseMitabLineParser(File file)
initialiseMitabLineParser.protected abstract void
initialiseMitabLineParser(InputStream input)
initialiseMitabLineParser.protected abstract void
initialiseMitabLineParser(Reader reader)
initialiseMitabLineParser.protected abstract void
initialiseMitabLineParser(URL url)
initialiseMitabLineParser.void
onAliasWithoutDbSource(MitabAlias alias)
onAliasWithoutDbSource.void
onAliasWithoutName(FileSourceContext context)
Listen to an event fired when an alias does not have a namevoid
onAnnotationWithoutTopic(FileSourceContext context)
Listen to an event fired when an annotation does not have a topicvoid
onEmptyUniqueIdentifiers(int line, int column, int mitabColumn)
onEmptyUniqueIdentifiers.void
onInteractionWithoutParticipants(Interaction interaction, FileSourceContext context)
Listen to an event fired when an interaction is read and does not have any participants.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)void
onInvalidPosition(String message, FileSourceContext context)
Listen to an event fired when a position is not validvoid
onInvalidRange(String message, FileSourceContext context)
Listen to an event fired when a range is not validvoid
onInvalidStoichiometry(String message, FileSourceContext context)
Listen to an event fired when a stoichiometry is not validvoid
onInvalidSyntax(FileSourceContext context, Exception e)
Listen to an invalid syntax causing an Exceptionvoid
onMissingChecksumMethod(FileSourceContext context)
Listen to an event fired when a checksum does not have a methodvoid
onMissingChecksumValue(FileSourceContext context)
Listen to an event fired when a checksum does not have a valuevoid
onMissingConfidenceType(FileSourceContext context)
Listen to an event fired when a confidence does not have a confidence typevoid
onMissingConfidenceValue(FileSourceContext context)
Listen to an event fired when a confidence does not have a valuevoid
onMissingCvTermName(CvTerm term, FileSourceContext context, String message)
Listen to an event fired when a CvTerm is read and does not have any names.void
onMissingExpansionId(MitabCvTerm expansion)
onMissingExpansionId.void
onMissingInteractorIdentifierColumns(int line, int column, int mitabColumn)
onMissingInteractorIdentifierColumns.void
onMissingInteractorName(Interactor interactor, FileSourceContext context)
Listen to an event fired when an interactor is read and does not have any names.void
onMissingParameterType(FileSourceContext context)
Listen to an event fired when a parameter does not have a typevoid
onMissingParameterValue(FileSourceContext context)
Listen to an event fired when a parameter does not have a valuevoid
onParticipantWithoutInteractor(Participant participant, FileSourceContext context)
Listen to en event fired when a Participant is read and no interactor details has been provided.void
onSeveralCreatedDateFound(Collection<MitabDate> dates)
onSeveralCreatedDateFound.void
onSeveralCvTermsFound(Collection<MitabCvTerm> terms, FileSourceContext context, String message)
Listen to an event where several CvTerms were found and only one was expected.void
onSeveralFirstAuthorFound(Collection<MitabAuthor> authors)
onSeveralFirstAuthorFound.void
onSeveralHostOrganismFound(Collection<MitabOrganism> organisms, FileSourceContext context)
Listen to an event where several host organisms were found in a single experiment and only one was expected.void
onSeveralOrganismFound(Collection<MitabOrganism> organisms)
onSeveralOrganismFound.void
onSeveralSourceFound(Collection<MitabSource> sources)
onSeveralSourceFound.void
onSeveralStoichiometryFound(Collection<MitabStoichiometry> stoichiometry)
onSeveralStoichiometryFound.void
onSeveralUniqueIdentifiers(Collection<MitabXref> ids)
onSeveralUniqueIdentifiers.void
onSeveralUpdatedDateFound(Collection<MitabDate> dates)
onSeveralUpdatedDateFound.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.void
onTextFoundInConfidence(MitabConfidence conf)
onTextFoundInConfidence.void
onTextFoundInIdentifier(MitabXref xref)
onTextFoundInIdentifier.void
onXrefWithoutDatabase(FileSourceContext context)
Listen to an event fired when a xref does not have a databasevoid
onXrefWithoutId(FileSourceContext context)
Listen to an event fired when a xref does not have an idprotected void
reInit()
reInit.void
reset()
reset.void
setFileParserListener(MIFileParserListener listener)
setFileParserListenervoid
setInteractorFactory(InteractorFactory interactorFactory)
Setter for the fieldinteractorFactory
.protected void
setLineParser(AbstractInteractionLineParser<T,P,F> lineParser)
Setter for the fieldlineParser
.protected void
setMIFileParserListener(MIFileParserListener listener)
setMIFileParserListener.protected void
setMitabFileParserListener(MitabParserListener listener)
setMitabFileParserListener.protected void
setOriginalFile(File originalFile)
Setter for the fieldoriginalFile
.protected void
setOriginalReader(Reader originalReader)
Setter for the fieldoriginalReader
.protected void
setOriginalStream(InputStream originalStream)
Setter for the fieldoriginalStream
.protected void
setOriginalURL(URL originalURL)
Setter for the fieldoriginalURL
.boolean
validateSyntax()
validateSyntax.boolean
validateSyntax(MIFileParserListener listener)
Validate the syntax of this MIFileDataSource and uses the provided MIFileParserListener to listen to the events.
-
-
-
Constructor Detail
-
AbstractMitabStreamSource
public AbstractMitabStreamSource()
Empty constructor for the factory
-
AbstractMitabStreamSource
public AbstractMitabStreamSource(File file) throws IOException
Constructor for AbstractMitabStreamSource.
- Parameters:
file
- aFile
object.- Throws:
IOException
- if any.
-
AbstractMitabStreamSource
public AbstractMitabStreamSource(InputStream input)
Constructor for AbstractMitabStreamSource.
- Parameters:
input
- aInputStream
object.
-
AbstractMitabStreamSource
public AbstractMitabStreamSource(Reader reader)
Constructor for AbstractMitabStreamSource.
- Parameters:
reader
- aReader
object.
-
-
Method Detail
-
getFileParserListener
public MIFileParserListener getFileParserListener()
getFileParserListener.
- Specified by:
getFileParserListener
in interfaceMIFileDataSource
- Returns:
- a
MIFileParserListener
object.
-
setFileParserListener
public void setFileParserListener(MIFileParserListener listener)
setFileParserListener
- Specified by:
setFileParserListener
in interfaceMIFileDataSource
- Parameters:
listener
- aMIFileParserListener
object.
-
initialiseContext
public void initialiseContext(Map<String,Object> options)
Initialise the context of the MIDataSource given a map of options- Specified by:
initialiseContext
in interfaceMIDataSource
- Parameters:
options
- : the options provided by the user
-
close
public void close() throws MIIOException
close.
- Specified by:
close
in interfaceMIDataSource
- Throws:
MIIOException
- if any.
-
reset
public void reset() throws MIIOException
reset.
- Specified by:
reset
in 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:
validateSyntax
in interfaceMIFileDataSource
- Parameters:
listener
- : the listener for parsing events- Returns:
- true if the file syntax is valid
-
validateSyntax
public boolean validateSyntax()
validateSyntax.
- Specified by:
validateSyntax
in interfaceMIFileDataSource
- Returns:
- a boolean.
-
onInvalidSyntax
public void onInvalidSyntax(FileSourceContext context, Exception e)
Listen to an invalid syntax causing an Exception- Specified by:
onInvalidSyntax
in interfaceMIFileParserListener
- Parameters:
context
- : file contexte
- aException
object.
-
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:
onSyntaxWarning
in 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:
onMissingCvTermName
in 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:
onMissingInteractorName
in interfaceMIFileParserListener
- Parameters:
interactor
- : interactor without namecontext
- : file context
-
onSeveralCvTermsFound
public void onSeveralCvTermsFound(Collection<MitabCvTerm> terms, FileSourceContext context, String message)
Listen to an event where several CvTerms were found and only one was expected. Can happen when reading a clustered interaction evidence for instance- Specified by:
onSeveralCvTermsFound
in interfaceMitabParserListener
- Parameters:
terms
- aCollection
object.context
- aFileSourceContext
object.message
- aString
object.
-
onSeveralHostOrganismFound
public void onSeveralHostOrganismFound(Collection<MitabOrganism> organisms, FileSourceContext context)
Listen to an event where several host organisms were found in a single experiment and only one was expected. Can happen when reading a clustered interaction evidence for instance- Specified by:
onSeveralHostOrganismFound
in interfaceMitabParserListener
- Parameters:
organisms
- aCollection
object.context
- aFileSourceContext
object.
-
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:
onParticipantWithoutInteractor
in 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:
onInteractionWithoutParticipants
in interfaceMIFileParserListener
- Parameters:
interaction
- : interaction without participantscontext
- : file context
-
onMissingInteractorIdentifierColumns
public void onMissingInteractorIdentifierColumns(int line, int column, int mitabColumn)
onMissingInteractorIdentifierColumns.
- Specified by:
onMissingInteractorIdentifierColumns
in interfaceMitabParserListener
- Parameters:
line
- a int.column
- a int.mitabColumn
- a int.
-
onSeveralOrganismFound
public void onSeveralOrganismFound(Collection<MitabOrganism> organisms)
onSeveralOrganismFound.
- Specified by:
onSeveralOrganismFound
in interfaceMitabParserListener
- Parameters:
organisms
- aCollection
object.
-
onSeveralStoichiometryFound
public void onSeveralStoichiometryFound(Collection<MitabStoichiometry> stoichiometry)
onSeveralStoichiometryFound.
- Specified by:
onSeveralStoichiometryFound
in interfaceMitabParserListener
- Parameters:
stoichiometry
- aCollection
object.
-
onSeveralFirstAuthorFound
public void onSeveralFirstAuthorFound(Collection<MitabAuthor> authors)
onSeveralFirstAuthorFound.
- Specified by:
onSeveralFirstAuthorFound
in interfaceMitabParserListener
- Parameters:
authors
- aCollection
object.
-
onSeveralSourceFound
public void onSeveralSourceFound(Collection<MitabSource> sources)
onSeveralSourceFound.
- Specified by:
onSeveralSourceFound
in interfaceMitabParserListener
- Parameters:
sources
- aCollection
object.
-
onSeveralCreatedDateFound
public void onSeveralCreatedDateFound(Collection<MitabDate> dates)
onSeveralCreatedDateFound.
- Specified by:
onSeveralCreatedDateFound
in interfaceMitabParserListener
- Parameters:
dates
- aCollection
object.
-
onSeveralUpdatedDateFound
public void onSeveralUpdatedDateFound(Collection<MitabDate> dates)
onSeveralUpdatedDateFound.
- Specified by:
onSeveralUpdatedDateFound
in interfaceMitabParserListener
- Parameters:
dates
- aCollection
object.
-
onTextFoundInIdentifier
public void onTextFoundInIdentifier(MitabXref xref)
onTextFoundInIdentifier.
- Specified by:
onTextFoundInIdentifier
in interfaceMitabParserListener
- Parameters:
xref
- aMitabXref
object.
-
onTextFoundInConfidence
public void onTextFoundInConfidence(MitabConfidence conf)
onTextFoundInConfidence.
- Specified by:
onTextFoundInConfidence
in interfaceMitabParserListener
- Parameters:
conf
- aMitabConfidence
object.
-
onMissingExpansionId
public void onMissingExpansionId(MitabCvTerm expansion)
onMissingExpansionId.
- Specified by:
onMissingExpansionId
in interfaceMitabParserListener
- Parameters:
expansion
- aMitabCvTerm
object.
-
onSeveralUniqueIdentifiers
public void onSeveralUniqueIdentifiers(Collection<MitabXref> ids)
onSeveralUniqueIdentifiers.
- Specified by:
onSeveralUniqueIdentifiers
in interfaceMitabParserListener
- Parameters:
ids
- aCollection
object.
-
onEmptyUniqueIdentifiers
public void onEmptyUniqueIdentifiers(int line, int column, int mitabColumn)
onEmptyUniqueIdentifiers.
- Specified by:
onEmptyUniqueIdentifiers
in interfaceMitabParserListener
- Parameters:
line
- a int.column
- a int.mitabColumn
- a int.
-
onAliasWithoutDbSource
public void onAliasWithoutDbSource(MitabAlias alias)
onAliasWithoutDbSource.
- Specified by:
onAliasWithoutDbSource
in interfaceMitabParserListener
- Parameters:
alias
- aMitabAlias
object.
-
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:
onInvalidOrganismTaxid
in 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:
onMissingParameterValue
in 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:
onMissingParameterType
in 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:
onMissingConfidenceValue
in 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:
onMissingConfidenceType
in 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:
onMissingChecksumValue
in 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:
onMissingChecksumMethod
in 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:
onInvalidPosition
in 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:
onInvalidRange
in 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:
onInvalidStoichiometry
in 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:
onXrefWithoutDatabase
in 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:
onXrefWithoutId
in 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:
onAnnotationWithoutTopic
in 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:
onAliasWithoutName
in interfaceMIFileParserListener
- Parameters:
context
- : file context
-
getInteractionsIterator
public Iterator<T> getInteractionsIterator()
getInteractionsIterator.
- Specified by:
getInteractionsIterator
in interfaceInteractionStream<T extends Interaction>
- Returns:
- a
Iterator
object.
-
getInteractorFactory
public InteractorFactory getInteractorFactory()
Getter for the field
interactorFactory
.- Returns:
- a
InteractorFactory
object.
-
setInteractorFactory
public void setInteractorFactory(InteractorFactory interactorFactory)
Setter for the field
interactorFactory
.- Parameters:
interactorFactory
- aInteractorFactory
object.
-
getLineParser
protected MitabLineParser<T,P,F> getLineParser()
Getter for the field
lineParser
.- Returns:
- a
MitabLineParser
object.
-
setLineParser
protected void setLineParser(AbstractInteractionLineParser<T,P,F> lineParser)
Setter for the field
lineParser
.- Parameters:
lineParser
- aAbstractInteractionLineParser
object.
-
initialiseMitabLineParser
protected abstract void initialiseMitabLineParser(Reader reader)
initialiseMitabLineParser.
- Parameters:
reader
- aReader
object.
-
initialiseMitabLineParser
protected abstract void initialiseMitabLineParser(File file)
initialiseMitabLineParser.
- Parameters:
file
- aFile
object.
-
initialiseMitabLineParser
protected abstract void initialiseMitabLineParser(InputStream input)
initialiseMitabLineParser.
- Parameters:
input
- aInputStream
object.
-
initialiseMitabLineParser
protected abstract void initialiseMitabLineParser(URL url)
initialiseMitabLineParser.
- Parameters:
url
- aURL
object.
-
createMitabIterator
protected abstract Iterator<T> createMitabIterator()
createMitabIterator.
- Returns:
- a
Iterator
object.
-
reInit
protected void reInit() throws MIIOException
reInit.
- Throws:
MIIOException
- if any.
-
setOriginalFile
protected void setOriginalFile(File originalFile)
Setter for the field
originalFile
.- Parameters:
originalFile
- aFile
object.
-
setOriginalStream
protected void setOriginalStream(InputStream originalStream)
Setter for the field
originalStream
.- Parameters:
originalStream
- aInputStream
object.
-
setOriginalReader
protected void setOriginalReader(Reader originalReader)
Setter for the field
originalReader
.- Parameters:
originalReader
- aReader
object.
-
setOriginalURL
protected void setOriginalURL(URL originalURL)
Setter for the field
originalURL
.- Parameters:
originalURL
- aURL
object.
-
setMitabFileParserListener
protected void setMitabFileParserListener(MitabParserListener listener)
setMitabFileParserListener.
- Parameters:
listener
- aMitabParserListener
object.
-
setMIFileParserListener
protected void setMIFileParserListener(MIFileParserListener listener)
setMIFileParserListener.
- Parameters:
listener
- aMIFileParserListener
object.
-
-