Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding first class Description field to SAMSequenceRecord #1209

Merged
merged 1 commit into from
Nov 14, 2018
Merged
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
4 changes: 4 additions & 0 deletions src/main/java/htsjdk/samtools/SAMSequenceRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class SAMSequenceRecord extends AbstractSAMHeaderRecord implements Clonea
public static final String ASSEMBLY_TAG = "AS";
public static final String URI_TAG = "UR";
public static final String SPECIES_TAG = "SP";
public static final String DESCRIPTION_TAG = "DS";

/** If one sequence has this length, and another sequence had a different length, isSameSequence will
* not complain that they are different sequences. */
Expand Down Expand Up @@ -123,6 +124,9 @@ private void setSequenceName(final String name) {
public String getMd5() { return (String) getAttribute(MD5_TAG); }
public void setMd5(final String value) { setAttribute(MD5_TAG, value); }

public String getDescription() { return getAttribute(DESCRIPTION_TAG);}
public void setDescription(final String value) { setAttribute(DESCRIPTION_TAG, value);}

/**
* @return Index of this record in the sequence dictionary it lives in.
*/
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/htsjdk/samtools/SAMSequenceRecordTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,13 @@ public void testIsSameSequence(final SAMSequenceRecord rec1 , final SAMSequenceR
Assert.assertEquals(rec1.isSameSequence(rec2), isSame);
}
}

@Test
public void testSetAndCheckDescription(){
final SAMSequenceRecord record = new SAMSequenceRecord("Test", 1000);
Assert.assertNull(record.getDescription());
final String description = "A description.";
record.setDescription(description);
Assert.assertEquals(record.getDescription(), description);
}
}