Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package org.biojava.nbio.core.sequence.features;

import java.util.ArrayList;
import java.util.List;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you document this Class with javadoc?

public class PublicationReference {

public enum ReferenceType {
UNKNOWN, PUBMED, PATENT, DIRECT_SUBMISSION;
}

private String id, title, journal;
private ReferenceType referenceType;
private List<PublicationReferenceAuthor> authors = new ArrayList<>();

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getJournal() {
return journal;
}

public void setJournal(String journal) {
this.journal = journal;
}

public ReferenceType getReferenceType() {
return referenceType;
}

public void setReferenceType(ReferenceType referenceType) {
this.referenceType = referenceType;
}

public List<PublicationReferenceAuthor> getAuthors() {
return authors;
}

public void setAuthors(List<PublicationReferenceAuthor> authors) {
this.authors = authors;
}

@Override
public String toString() {
return "PublicationReference{" +
"id='" + id + '\'' +
", title='" + title + '\'' +
", journal='" + journal + '\'' +
", referenceType=" + referenceType +
", authors=" + authors +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

PublicationReference that = (PublicationReference) o;

if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (title != null ? !title.equals(that.title) : that.title != null) return false;
if (journal != null ? !journal.equals(that.journal) : that.journal != null) return false;
if (referenceType != that.referenceType) return false;
return authors != null ? authors.equals(that.authors) : that.authors == null;

}

@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (title != null ? title.hashCode() : 0);
result = 31 * result + (journal != null ? journal.hashCode() : 0);
result = 31 * result + (referenceType != null ? referenceType.hashCode() : 0);
result = 31 * result + (authors != null ? authors.hashCode() : 0);
return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.biojava.nbio.core.sequence.features;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you document this Class with javadoc?

public class PublicationReferenceAuthor {

private String firstName, lastName, fullName;

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getFullName() {
return fullName;
}

public void setFullName(String fullName) {
this.fullName = fullName;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

PublicationReferenceAuthor that = (PublicationReferenceAuthor) o;

if (firstName != null ? !firstName.equals(that.firstName) : that.firstName != null) return false;
if (lastName != null ? !lastName.equals(that.lastName) : that.lastName != null) return false;
return fullName != null ? fullName.equals(that.fullName) : that.fullName == null;

}

@Override
public int hashCode() {
int result = firstName != null ? firstName.hashCode() : 0;
result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
result = 31 * result + (fullName != null ? fullName.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "PublicationAuthor{" +
"firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", fullName='" + fullName + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.biojava.nbio.core.sequence.compound.NucleotideCompound;
import org.biojava.nbio.core.sequence.features.AbstractFeature;
import org.biojava.nbio.core.sequence.features.DBReferenceInfo;
import org.biojava.nbio.core.sequence.features.PublicationReference;
import org.biojava.nbio.core.sequence.io.template.SequenceCreatorInterface;
import org.biojava.nbio.core.sequence.io.template.SequenceHeaderParserInterface;
import org.biojava.nbio.core.sequence.template.AbstractSequence;
Expand All @@ -45,6 +46,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;

/**
* Use GenbankReaderHelper as an example of how to use this class where GenbankReaderHelper should be the
Expand Down Expand Up @@ -148,6 +150,12 @@ public LinkedHashMap<String,S> process(int max) throws IOException, CompoundNotF
S sequence = (S) sequenceCreator.getSequence(seqString, 0);
genbankParser.getSequenceHeaderParser().parseHeader(genbankParser.getHeader(), sequence);

sequence.setPublicationReference(genbankParser.getPublicationReferences());
sequence.setKeywords(genbankParser.getKeyWords());
sequence.setSource(genbankParser.getSource());
sequence.setOrganism(genbankParser.getOrganism());
sequence.setComment(genbankParser.getComment());

// add features to new sequence
for (String k: genbankParser.getFeatures().keySet()){
for (AbstractFeature f: genbankParser.getFeatures(k)){
Expand All @@ -163,6 +171,8 @@ public LinkedHashMap<String,S> process(int max) throws IOException, CompoundNotF
sequence.setTaxonomy(new TaxonomyID(q.getDatabase()+":"+q.getId(), DataSource.GENBANK));
}



sequences.put(sequence.getAccession().getID(), sequence);
}
br.close();
Expand Down
Loading