{"action":"created","issue":{"url":"https://api.github.com/repos/samtools/htsjdk/issues/401","repository_url":"https://api.github.com/repos/samtools/htsjdk","labels_url":"https://api.github.com/repos/samtools/htsjdk/issues/401/labels{/name}","comments_url":"https://api.github.com/repos/samtools/htsjdk/issues/401/comments","events_url":"https://api.github.com/repos/samtools/htsjdk/issues/401/events","html_url":"https://github.com/samtools/htsjdk/issues/401","id":120032121,"number":401,"title":"Figure out there is a bug in BAMIndexMetaData.recordMetaData","user":{"login":"lbergelson","id":4700332,"avatar_url":"https://avatars.githubusercontent.com/u/4700332?v=3","gravatar_id":"","url":"https://api.github.com/users/lbergelson","html_url":"https://github.com/lbergelson","followers_url":"https://api.github.com/users/lbergelson/followers","following_url":"https://api.github.com/users/lbergelson/following{/other_user}","gists_url":"https://api.github.com/users/lbergelson/gists{/gist_id}","starred_url":"https://api.github.com/users/lbergelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbergelson/subscriptions","organizations_url":"https://api.github.com/users/lbergelson/orgs","repos_url":"https://api.github.com/users/lbergelson/repos","events_url":"https://api.github.com/users/lbergelson/events{/privacy}","received_events_url":"https://api.github.com/users/lbergelson/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/samtools/htsjdk/labels/discussion","name":"discussion","color":"5319e7"}],"state":"open","locked":false,"assignee":{"login":"vadimzalunin","id":668644,"avatar_url":"https://avatars.githubusercontent.com/u/668644?v=3","gravatar_id":"","url":"https://api.github.com/users/vadimzalunin","html_url":"https://github.com/vadimzalunin","followers_url":"https://api.github.com/users/vadimzalunin/followers","following_url":"https://api.github.com/users/vadimzalunin/following{/other_user}","gists_url":"https://api.github.com/users/vadimzalunin/gists{/gist_id}","starred_url":"https://api.github.com/users/vadimzalunin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vadimzalunin/subscriptions","organizations_url":"https://api.github.com/users/vadimzalunin/orgs","repos_url":"https://api.github.com/users/vadimzalunin/repos","events_url":"https://api.github.com/users/vadimzalunin/events{/privacy}","received_events_url":"https://api.github.com/users/vadimzalunin/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-12-02T20:43:53Z","updated_at":"2016-02-17T10:28:10Z","closed_at":null,"body":"@vadimzalunin I noticed this and I wanted to know if it's a bug or if it's deliberate.  If it's deliberate it's confusing.\r\n\r\nI'm not really sure what is supposed to happen, so it's hard for me to tell if the logic is correct.\r\n\r\n`start` and `end` are being set to the same value.  \r\n\r\n```java\r\n  void recordMetaData(Slice slice) {\r\n\r\n        final int alignmentStart = slice.alignmentStart;\r\n        if (alignmentStart == SAMRecord.NO_ALIGNMENT_START) {\r\n            incrementNoCoordinateRecordCount();\r\n            return;\r\n        }\r\n\r\n        final long start = slice.offset;\r\n        final long end = slice.offset + 0;\r\n\r\n        if (slice.alignmentSpan < 1) {\r\n            unAlignedRecords += slice.nofRecords;\r\n        } else {\r\n            alignedRecords += slice.nofRecords;\r\n        }\r\n        if (BlockCompressedFilePointerUtil.compare(start, firstOffset) < 1 || firstOffset == -1) {\r\n            this.firstOffset = start;\r\n        }\r\n        if (BlockCompressedFilePointerUtil.compare(lastOffset, end) < 1) {\r\n            this.lastOffset = end;\r\n        }\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/samtools/htsjdk/issues/comments/185141725","html_url":"https://github.com/samtools/htsjdk/issues/401#issuecomment-185141725","issue_url":"https://api.github.com/repos/samtools/htsjdk/issues/401","id":185141725,"user":{"login":"vadimzalunin","id":668644,"avatar_url":"https://avatars.githubusercontent.com/u/668644?v=3","gravatar_id":"","url":"https://api.github.com/users/vadimzalunin","html_url":"https://github.com/vadimzalunin","followers_url":"https://api.github.com/users/vadimzalunin/followers","following_url":"https://api.github.com/users/vadimzalunin/following{/other_user}","gists_url":"https://api.github.com/users/vadimzalunin/gists{/gist_id}","starred_url":"https://api.github.com/users/vadimzalunin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vadimzalunin/subscriptions","organizations_url":"https://api.github.com/users/vadimzalunin/orgs","repos_url":"https://api.github.com/users/vadimzalunin/repos","events_url":"https://api.github.com/users/vadimzalunin/events{/privacy}","received_events_url":"https://api.github.com/users/vadimzalunin/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T10:28:10Z","updated_at":"2016-02-17T10:28:10Z","body":"Short story: effectively 'end' is not used in CRAM random access. Perhaps since 'end' is exclusive then it would be cleaner to set it to offset+1.\r\n\r\nMore words:\r\nThis is because slices are addressed via landmarks. The 16 bits of BAI pointer is not enough to address bytes within container which is normally 100k-1m bytes long. Instead of byte offset BAI pointers are used to store the ordinal index of slices in a container. And container ladnmarks array contains byte offsets for each slice in the same order. \r\nGiven that each pointer always addresses a single slice there is no need for 'end' value, just 'start' will do. \r\n\r\n"}}