Skip to content

Commit

Permalink
Adding first class Description field to SAMSequenceRecord (#1209)
Browse files Browse the repository at this point in the history
* The @sq DS header field was added to the 1.6 bam spec, this adds a getter and setter for it.
* We do not correctly support UTF-8 characters in description due to #1202
  • Loading branch information
lbergelson authored Nov 14, 2018
1 parent bc4b3ae commit ce97a5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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);
}
}

0 comments on commit ce97a5f

Please sign in to comment.